Fixed contains issue
This commit is contained in:
parent
bc3a8b48f0
commit
52ab728404
1 changed files with 8 additions and 13 deletions
|
|
@ -54,9 +54,13 @@ public class NutUPSClient {
|
||||||
|
|
||||||
public UPSDevice getUPS(String id){
|
public UPSDevice getUPS(String id){
|
||||||
update();
|
update();
|
||||||
int i = upsDevices.indexOf(id);
|
return __getUPS(id);
|
||||||
if (i >= 0)
|
}
|
||||||
return upsDevices.get(i);
|
private UPSDevice __getUPS(String id){
|
||||||
|
for (UPSDevice ups : upsDevices){
|
||||||
|
if (ups.equals(id))
|
||||||
|
return ups;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,7 +81,7 @@ public class NutUPSClient {
|
||||||
HashMap<String,String> tmp = new HashMap<>();
|
HashMap<String,String> tmp = new HashMap<>();
|
||||||
sendListCommand(out, in, "UPS", tmp);
|
sendListCommand(out, in, "UPS", tmp);
|
||||||
for (String upsId : tmp.keySet()){
|
for (String upsId : tmp.keySet()){
|
||||||
if(!upsDevices.contains(upsId)) {
|
if(__getUPS(upsId) == null) {
|
||||||
logger.fine("Registering new UPS device: "+upsId);
|
logger.fine("Registering new UPS device: "+upsId);
|
||||||
upsDevices.add(new UPSDevice(upsId));
|
upsDevices.add(new UPSDevice(upsId));
|
||||||
}
|
}
|
||||||
|
|
@ -118,15 +122,6 @@ public class NutUPSClient {
|
||||||
m.group(1),
|
m.group(1),
|
||||||
m.group(2));
|
m.group(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*while ((line=in.readLine()) != null){
|
|
||||||
if (line.startsWith("END"))
|
|
||||||
break;
|
|
||||||
String[] strArr = line.split("\\W+", 3);
|
|
||||||
parameters.put(
|
|
||||||
strArr[1],
|
|
||||||
StringUtil.trim(strArr[2], '\"'));
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue