[caddx] Changed Hashmap keys from BigDecimal to int (#13521)

Signed-off-by: Georgios Moutsos <georgios.moutsos@gmail.com>
This commit is contained in:
Georgios Moutsos 2022-10-09 10:41:34 +03:00 committed by GitHub
parent 337241f40e
commit 7f1a096dca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,9 +90,9 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
private @Nullable CaddxCommunicator communicator = null; private @Nullable CaddxCommunicator communicator = null;
// Things served by the bridge // Things served by the bridge
private Map<BigDecimal, Thing> thingZonesMap = new ConcurrentHashMap<>(); private Map<Integer, Thing> thingZonesMap = new ConcurrentHashMap<>();
private Map<BigDecimal, Thing> thingPartitionsMap = new ConcurrentHashMap<>(); private Map<Integer, Thing> thingPartitionsMap = new ConcurrentHashMap<>();
private Map<BigDecimal, Thing> thingKeypadsMap = new ConcurrentHashMap<>(); private Map<Integer, Thing> thingKeypadsMap = new ConcurrentHashMap<>();
private @Nullable Thing thingPanel = null; private @Nullable Thing thingPanel = null;
public @Nullable CaddxDiscoveryService getDiscoveryService() { public @Nullable CaddxDiscoveryService getDiscoveryService() {
@ -163,9 +163,9 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
// Send status commands to the zones and partitions // Send status commands to the zones and partitions
thingZonesMap.forEach((k, v) -> sendCommand(CaddxMessageContext.COMMAND, thingZonesMap.forEach((k, v) -> sendCommand(CaddxMessageContext.COMMAND,
CaddxBindingConstants.ZONE_STATUS_REQUEST, k.subtract(BigDecimal.ONE).toString())); CaddxBindingConstants.ZONE_STATUS_REQUEST, String.valueOf(k - 1)));
thingPartitionsMap.forEach((k, v) -> sendCommand(CaddxMessageContext.COMMAND, thingPartitionsMap.forEach((k, v) -> sendCommand(CaddxMessageContext.COMMAND,
CaddxBindingConstants.PARTITION_STATUS_REQUEST, k.subtract(BigDecimal.ONE).toString())); CaddxBindingConstants.PARTITION_STATUS_REQUEST, String.valueOf(k - 1)));
} }
// list all channels // list all channels
@ -197,15 +197,15 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
switch (caddxThingType) { switch (caddxThingType) {
case PARTITION: case PARTITION:
if (partition != null) { if (partition != null) {
return thingPartitionsMap.get(BigDecimal.valueOf(partition)); return thingPartitionsMap.get(Integer.valueOf(partition));
} }
case ZONE: case ZONE:
if (zone != null) { if (zone != null) {
return thingZonesMap.get(BigDecimal.valueOf(zone)); return thingZonesMap.get(Integer.valueOf(zone));
} }
case KEYPAD: case KEYPAD:
if (keypad != null) { if (keypad != null) {
return thingKeypadsMap.get(BigDecimal.valueOf(keypad)); return thingKeypadsMap.get(Integer.valueOf(keypad));
} }
case PANEL: case PANEL:
return thingPanel; return thingPanel;
@ -412,14 +412,15 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
@Override @Override
public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) { public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
if (childHandler instanceof ThingHandlerPartition) { if (childHandler instanceof ThingHandlerPartition) {
BigDecimal id = (BigDecimal) childThing.getConfiguration() int id = ((BigDecimal) childThing.getConfiguration().get(CaddxPartitionConfiguration.PARTITION_NUMBER))
.get(CaddxPartitionConfiguration.PARTITION_NUMBER); .intValue();
thingPartitionsMap.put(id, childThing); thingPartitionsMap.put(id, childThing);
} else if (childHandler instanceof ThingHandlerZone) { } else if (childHandler instanceof ThingHandlerZone) {
BigDecimal id = (BigDecimal) childThing.getConfiguration().get(CaddxZoneConfiguration.ZONE_NUMBER); int id = ((BigDecimal) childThing.getConfiguration().get(CaddxZoneConfiguration.ZONE_NUMBER)).intValue();
thingZonesMap.put(id, childThing); thingZonesMap.put(id, childThing);
} else if (childHandler instanceof ThingHandlerKeypad) { } else if (childHandler instanceof ThingHandlerKeypad) {
BigDecimal id = (BigDecimal) childThing.getConfiguration().get(CaddxKeypadConfiguration.KEYPAD_ADDRESS); int id = ((BigDecimal) childThing.getConfiguration().get(CaddxKeypadConfiguration.KEYPAD_ADDRESS))
.intValue();
thingKeypadsMap.put(id, childThing); thingKeypadsMap.put(id, childThing);
} else if (childHandler instanceof ThingHandlerPanel) { } else if (childHandler instanceof ThingHandlerPanel) {
thingPanel = childThing; thingPanel = childThing;
@ -431,14 +432,15 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
@Override @Override
public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) { public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
if (childHandler instanceof ThingHandlerPartition) { if (childHandler instanceof ThingHandlerPartition) {
BigDecimal id = (BigDecimal) childThing.getConfiguration() int id = ((BigDecimal) childThing.getConfiguration().get(CaddxPartitionConfiguration.PARTITION_NUMBER))
.get(CaddxPartitionConfiguration.PARTITION_NUMBER); .intValue();
thingPartitionsMap.remove(id); thingPartitionsMap.remove(id);
} else if (childHandler instanceof ThingHandlerZone) { } else if (childHandler instanceof ThingHandlerZone) {
BigDecimal id = (BigDecimal) childThing.getConfiguration().get(CaddxZoneConfiguration.ZONE_NUMBER); int id = ((BigDecimal) childThing.getConfiguration().get(CaddxZoneConfiguration.ZONE_NUMBER)).intValue();
thingZonesMap.remove(id); thingZonesMap.remove(id);
} else if (childHandler instanceof ThingHandlerKeypad) { } else if (childHandler instanceof ThingHandlerKeypad) {
BigDecimal id = (BigDecimal) childThing.getConfiguration().get(CaddxKeypadConfiguration.KEYPAD_ADDRESS); int id = ((BigDecimal) childThing.getConfiguration().get(CaddxKeypadConfiguration.KEYPAD_ADDRESS))
.intValue();
thingKeypadsMap.remove(id); thingKeypadsMap.remove(id);
} else if (childHandler instanceof ThingHandlerPanel) { } else if (childHandler instanceof ThingHandlerPanel) {
thingPanel = null; thingPanel = null;