private static Properties getValue(String[] variants) throws NoKeyException
{
Properties properties = new Properties();
for (String variant : variants) {
String key = variant;
String value = monitorClient.getValue(key);
if(value == null)
throw new NoKeyException(variant);
properties.put(variant, value);
}
return properties;
}读不懂这个方法里的每一行意思,求解!
{
Properties properties = new Properties();
for (String variant : variants) {
String key = variant;
String value = monitorClient.getValue(key);
if(value == null)
throw new NoKeyException(variant);
properties.put(variant, value);
}
return properties;
}读不懂这个方法里的每一行意思,求解!
然后获取这些key在monitorClient里是否存在
不存在就抛出NoKey异常 存在就put进properties里
{
Properties properties = new Properties();//创建properties对象,Properties类是HashMap的子类,其最大的特点是Key和Value都是String
for (String variant : variants) {//通过遍历传进来的variants数组中的每一个元素
String key = variant;//设置key
String value = monitorClient.getValue(key);//取出monitorClient中与key对应的value
if(value == null)//判断value是否为空,若不为空,将对应的key和value添加至properties对象中。若为空,抛出NoKeyException异常
throw new NoKeyException(variant);
properties.put(variant, value);
}
return properties;
}
private static Properties getValue(String[] variants) throws NoKeyException
{
Properties properties = new Properties();// 创建properties对象,Properties类是HashMap的子类,其最大的特点是Key和Value都是String
for (String variant : variants)
{// 通过遍历传进来的variants数组中的每一个元素
String key = variant;// 设置key
String value = monitorClient.getValue(key);// 取出monitorClient中与key对应的value
if (value == null) // 判断value是否为空,若不为空,将对应的key和value添加至properties对象中。若为空,抛出NoKeyException异常
throw new NoKeyException(variant);
properties.put(variant, value);
}
return properties;
}