diff --git a/bundles/org.openhab.automation.pwm/src/main/java/org/openhab/automation/pwm/internal/handler/state/State.java b/bundles/org.openhab.automation.pwm/src/main/java/org/openhab/automation/pwm/internal/handler/state/State.java index 2bf490b5e..2461cc74e 100644 --- a/bundles/org.openhab.automation.pwm/src/main/java/org/openhab/automation/pwm/internal/handler/state/State.java +++ b/bundles/org.openhab.automation.pwm/src/main/java/org/openhab/automation/pwm/internal/handler/state/State.java @@ -50,6 +50,7 @@ public abstract class State { /** * Sets a new state in the state machine. */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") public synchronized void nextState(Function nextState) { if (context.getState() != this) { // compare identity return; diff --git a/bundles/org.openhab.binding.amazondashbutton/src/main/java/org/openhab/binding/amazondashbutton/internal/capturing/PacketCapturingService.java b/bundles/org.openhab.binding.amazondashbutton/src/main/java/org/openhab/binding/amazondashbutton/internal/capturing/PacketCapturingService.java index 68c834955..0d671cb86 100644 --- a/bundles/org.openhab.binding.amazondashbutton/src/main/java/org/openhab/binding/amazondashbutton/internal/capturing/PacketCapturingService.java +++ b/bundles/org.openhab.binding.amazondashbutton/src/main/java/org/openhab/binding/amazondashbutton/internal/capturing/PacketCapturingService.java @@ -137,6 +137,7 @@ public class PacketCapturingService { * @param packet The packet to be checked * @return Returns true, if the packet should be captured, otherwise false */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") private boolean shouldCapture(final Packet packet) { if (packet.contains(ArpPacket.class)) { ArpPacket arpPacket = packet.get(ArpPacket.class); diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java index d81d2a19a..6ebc28406 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java @@ -173,7 +173,7 @@ public class AccountServlet extends HttpServlet { + uri.substring(PROXY_URI_PART.length()); String postData = null; - if (verb == "POST" || verb == "PUT") { + if ("POST".equals(verb) || "PUT".equals(verb)) { postData = req.getReader().lines().collect(Collectors.joining(System.lineSeparator())); } diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/FlashBriefingProfileHandler.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/FlashBriefingProfileHandler.java index b665efaca..865c9953a 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/FlashBriefingProfileHandler.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/FlashBriefingProfileHandler.java @@ -157,6 +157,7 @@ public class FlashBriefingProfileHandler extends BaseThingHandler { } } + @SuppressWarnings("PMD.CompareObjectsWithEquals") public boolean initialize(AccountHandler handler, String currentConfigurationJson) { updateState(CHANNEL_SAVE, OnOffType.OFF); if (updatePlayOnDevice) { diff --git a/bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/net/SocketChannelSession.java b/bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/net/SocketChannelSession.java index f437eab8a..63148ac6c 100644 --- a/bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/net/SocketChannelSession.java +++ b/bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/net/SocketChannelSession.java @@ -319,6 +319,7 @@ public class SocketChannelSession implements SocketSession { * Stops the reader. Will wait 5 seconds for the runnable to stop (should stop within 1 second based on the poll * timeout below) */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void stopRunning() { if (isRunning.getAndSet(false)) { // only wait if stopRunning didn't get called as part of processing a message diff --git a/bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3PortocolHandler.java b/bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3PortocolHandler.java index 5bf66f38c..4192aa946 100644 --- a/bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3PortocolHandler.java +++ b/bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3PortocolHandler.java @@ -1088,7 +1088,7 @@ class AtlonaPro3PortocolHandler { @Override public void responseReceived(String response) { - if (response == null || response == "") { + if (response == null || response.isEmpty()) { return; } diff --git a/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java b/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java index 0766da21f..0591007d8 100644 --- a/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java +++ b/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java @@ -554,6 +554,6 @@ public class AutelisHandler extends BaseThingHandler { } private boolean isJandy() { - return getThing().getThingTypeUID() == AutelisBindingConstants.JANDY_THING_TYPE_UID; + return AutelisBindingConstants.JANDY_THING_TYPE_UID.equals(getThing().getThingTypeUID()); } } diff --git a/bundles/org.openhab.binding.bluetooth.bluez/src/main/java/org/openhab/binding/bluetooth/bluez/internal/BlueZBluetoothDevice.java b/bundles/org.openhab.binding.bluetooth.bluez/src/main/java/org/openhab/binding/bluetooth/bluez/internal/BlueZBluetoothDevice.java index 4f865323a..531769122 100644 --- a/bundles/org.openhab.binding.bluetooth.bluez/src/main/java/org/openhab/binding/bluetooth/bluez/internal/BlueZBluetoothDevice.java +++ b/bundles/org.openhab.binding.bluetooth.bluez/src/main/java/org/openhab/binding/bluetooth/bluez/internal/BlueZBluetoothDevice.java @@ -83,6 +83,7 @@ public class BlueZBluetoothDevice extends BaseBluetoothDevice implements BlueZEv logger.debug("Creating DBusBlueZ device with address '{}'", address); } + @SuppressWarnings("PMD.CompareObjectsWithEquals") public synchronized void updateBlueZDevice(@Nullable BluetoothDevice blueZDevice) { if (this.device != null && this.device == blueZDevice) { return; diff --git a/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBluetoothDevice.java b/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBluetoothDevice.java index 4ad7a0b25..ef3a97682 100644 --- a/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBluetoothDevice.java +++ b/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBluetoothDevice.java @@ -104,6 +104,7 @@ public class RoamingBluetoothDevice extends DelegateBluetoothDevice { return getAdapter(currentDelegateRef.get()); } + @SuppressWarnings("PMD.CompareObjectsWithEquals") private class Listener implements BluetoothDeviceListener { private BluetoothDevice device; diff --git a/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBridgeHandler.java b/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBridgeHandler.java index 2fea7a33e..b1bacfbf4 100644 --- a/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBridgeHandler.java +++ b/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBridgeHandler.java @@ -143,6 +143,7 @@ public class RoamingBridgeHandler extends BaseBridgeHandler implements RoamingBl } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void addBluetoothAdapter(BluetoothAdapter adapter) { if (adapter == this) { return; @@ -164,6 +165,7 @@ public class RoamingBridgeHandler extends BaseBridgeHandler implements RoamingBl } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void removeBluetoothAdapter(BluetoothAdapter adapter) { if (adapter == this) { return; diff --git a/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/ConnectedBluetoothHandler.java b/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/ConnectedBluetoothHandler.java index 556b23ee2..b53f30219 100644 --- a/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/ConnectedBluetoothHandler.java +++ b/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/ConnectedBluetoothHandler.java @@ -109,6 +109,7 @@ public class ConnectedBluetoothHandler extends BeaconBluetoothHandler { } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void dispose() { cancel(reconnectJob, true); reconnectJob = null; @@ -181,6 +182,7 @@ public class ConnectedBluetoothHandler extends BeaconBluetoothHandler { return characteristic; } + @SuppressWarnings("PMD.CompareObjectsWithEquals") private CompletableFuture executeWithConnection(UUID serviceUUID, UUID characteristicUUID, Function> callable) { if (connectionTaskExecutor == scheduler) { diff --git a/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/util/HeritableFuture.java b/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/util/HeritableFuture.java index 2b96d2f1f..c7337da9d 100644 --- a/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/util/HeritableFuture.java +++ b/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/util/HeritableFuture.java @@ -67,6 +67,7 @@ public class HeritableFuture extends CompletableFuture { return new HeritableFuture<>(this); } + @SuppressWarnings("PMD.CompareObjectsWithEquals") protected void setParentFuture(Supplier<@Nullable Future> futureSupplier) { synchronized (futureLock) { var future = futureSupplier.get(); diff --git a/bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ConnectedDriveProxy.java b/bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ConnectedDriveProxy.java index dd383a3a4..0a8c80e57 100644 --- a/bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ConnectedDriveProxy.java +++ b/bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ConnectedDriveProxy.java @@ -291,7 +291,7 @@ public class ConnectedDriveProxy { ContentResponse authResponse = authRequest.timeout(HTTP_TIMEOUT_SEC, TimeUnit.SECONDS).send(); String authResponseString = URLDecoder.decode(authResponse.getContentAsString(), Charset.defaultCharset()); String authCode = getAuthCode(authResponseString); - if (authCode != Constants.EMPTY) { + if (!Constants.EMPTY.equals(authCode)) { MultiMap codeChallenge = getTokenBaseValues(); codeChallenge.put(AUTHORIZATION, authCode); diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Enums.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Enums.java index 2dfa4c2db..e0cb83d1f 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Enums.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Enums.java @@ -171,11 +171,11 @@ public class Enums { * @return the enum value representing the given measure unit */ public static MeasureUnit fromUnit(Unit unit) { - if (unit == SIUnits.CELSIUS) { + if (SIUnits.CELSIUS.equals(unit)) { return CELSIUS; - } else if (unit == ImperialUnits.FAHRENHEIT) { + } else if (ImperialUnits.FAHRENHEIT.equals(unit)) { return FAHRENHEIT; - } else if (unit == Units.PERCENT) { + } else if (Units.PERCENT.equals(unit)) { return PERCENTAGE; } else { return DIMENSIONLESS; diff --git a/bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/CaddxBaseThingHandler.java b/bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/CaddxBaseThingHandler.java index ef1bcd09d..aa0d8bae7 100644 --- a/bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/CaddxBaseThingHandler.java +++ b/bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/CaddxBaseThingHandler.java @@ -235,7 +235,7 @@ public abstract class CaddxBaseThingHandler extends BaseThingHandler { List channels = getThing().getChannels(); for (Channel ch : channels) { - if (channelUID == ch.getUID()) { + if (channelUID.equals(ch.getUID())) { channel = ch; break; } diff --git a/bundles/org.openhab.binding.comfoair/src/main/java/org/openhab/binding/comfoair/internal/ComfoAirCommandType.java b/bundles/org.openhab.binding.comfoair/src/main/java/org/openhab/binding/comfoair/internal/ComfoAirCommandType.java index 61aa83511..18db27fe8 100644 --- a/bundles/org.openhab.binding.comfoair/src/main/java/org/openhab/binding/comfoair/internal/ComfoAirCommandType.java +++ b/bundles/org.openhab.binding.comfoair/src/main/java/org/openhab/binding/comfoair/internal/ComfoAirCommandType.java @@ -786,6 +786,7 @@ public enum ComfoAirCommandType { * new state * @return initialized ComfoAirCommand */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") public static @Nullable ComfoAirCommand getChangeCommand(String key, Command command) { ComfoAirCommandType commandType = getCommandTypeByKey(key); State value = UnDefType.NULL; diff --git a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/DeviceStatusManagerImpl.java b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/DeviceStatusManagerImpl.java index cf6989436..af9689936 100644 --- a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/DeviceStatusManagerImpl.java +++ b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/DeviceStatusManagerImpl.java @@ -19,6 +19,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -463,8 +464,8 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager { } sendComandsToDSS(device, intDeviceStateUpdate); if (nextDeviceStateUpdate != null) { - if (intDeviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_CONFIG - || intDeviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_OUTPUT) { + if (DeviceStateUpdate.UPDATE_SCENE_CONFIG.equals(intDeviceStateUpdate.getType()) + || DeviceStateUpdate.UPDATE_SCENE_OUTPUT.equals(intDeviceStateUpdate.getType())) { updateSceneData(device, intDeviceStateUpdate); } else { sendComandsToDSS(device, intDeviceStateUpdate); @@ -625,7 +626,7 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager { // to // OFFLINE. // An alternate algorithm is responsible for deletion. - if (newDevice.isPresent() != internalDevice.isPresent()) { + if (!Objects.equals(newDevice.isPresent(), internalDevice.isPresent())) { internalDevice.setIsPresent(newDevice.isPresent()); } if (newDevice.getMeterDSID() != null && !newDevice.getMeterDSID().equals(internalDevice.getMeterDSID())) { @@ -757,9 +758,9 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager { while (!device.isDeviceUpToDate()) { DeviceStateUpdate deviceStateUpdate = device.getNextDeviceUpdateState(); if (deviceStateUpdate != null) { - if (deviceStateUpdate.getType() != DeviceStateUpdate.OUTPUT) { - if (deviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_CONFIG - || deviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_OUTPUT) { + if (!DeviceStateUpdate.OUTPUT.equals(deviceStateUpdate.getType())) { + if (DeviceStateUpdate.UPDATE_SCENE_CONFIG.equals(deviceStateUpdate.getType()) + || DeviceStateUpdate.UPDATE_SCENE_OUTPUT.equals(deviceStateUpdate.getType())) { updateSceneData(device, deviceStateUpdate); } else { sendComandsToDSS(device, deviceStateUpdate); @@ -767,14 +768,14 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager { } else { DeviceStateUpdate nextDeviceStateUpdate = device.getNextDeviceUpdateState(); while (nextDeviceStateUpdate != null - && nextDeviceStateUpdate.getType() == DeviceStateUpdate.OUTPUT) { + && DeviceStateUpdate.OUTPUT.equals(nextDeviceStateUpdate.getType())) { deviceStateUpdate = nextDeviceStateUpdate; nextDeviceStateUpdate = device.getNextDeviceUpdateState(); } sendComandsToDSS(device, deviceStateUpdate); if (nextDeviceStateUpdate != null) { - if (deviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_CONFIG - || deviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_OUTPUT) { + if (DeviceStateUpdate.UPDATE_SCENE_CONFIG.equals(deviceStateUpdate.getType()) + || DeviceStateUpdate.UPDATE_SCENE_OUTPUT.equals(deviceStateUpdate.getType())) { updateSceneData(device, deviceStateUpdate); } else { sendComandsToDSS(device, deviceStateUpdate); diff --git a/bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/TunableWhiteThingHandler.java b/bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/TunableWhiteThingHandler.java index 3f363e8e5..9c3b34d80 100644 --- a/bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/TunableWhiteThingHandler.java +++ b/bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/TunableWhiteThingHandler.java @@ -314,7 +314,7 @@ public class TunableWhiteThingHandler extends DmxThingHandler { private void updateCurrentBrightnessAndTemperature() { currentBrightness = Util.toPercentValue(Util.toDmxValue(currentValues.get(0) + currentValues.get(1))); - if (currentBrightness != PercentType.ZERO) { + if (!PercentType.ZERO.equals(currentBrightness)) { currentColorTemperature = new PercentType( 100 * currentValues.get(1) / (currentValues.get(0) + currentValues.get(1))); } diff --git a/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/DSCAlarmBaseThingHandler.java b/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/DSCAlarmBaseThingHandler.java index 4355dee06..98616e996 100644 --- a/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/DSCAlarmBaseThingHandler.java +++ b/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/DSCAlarmBaseThingHandler.java @@ -322,7 +322,7 @@ public abstract class DSCAlarmBaseThingHandler extends BaseThingHandler { List channels = getThing().getChannels(); for (Channel ch : channels) { - if (channelUID == ch.getUID()) { + if (ch.getUID().equals(channelUID)) { channel = ch; break; } diff --git a/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/KeypadThingHandler.java b/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/KeypadThingHandler.java index 08558ceb7..426d13513 100644 --- a/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/KeypadThingHandler.java +++ b/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/KeypadThingHandler.java @@ -100,40 +100,34 @@ public class KeypadThingHandler extends DSCAlarmBaseThingHandler { String[] channelTypes = { KEYPAD_READY_LED, KEYPAD_ARMED_LED, KEYPAD_MEMORY_LED, KEYPAD_BYPASS_LED, KEYPAD_TROUBLE_LED, KEYPAD_PROGRAM_LED, KEYPAD_FIRE_LED, KEYPAD_BACKLIGHT_LED }; - String channel; - ChannelUID channelUID = null; DSCAlarmCode dscAlarmCode = DSCAlarmCode .getDSCAlarmCodeValue(dscAlarmMessage.getMessageInfo(DSCAlarmMessageInfoType.CODE)); + int bitCount = 8; int bitField = Integer.decode("0x" + dscAlarmMessage.getMessageInfo(DSCAlarmMessageInfoType.DATA)); int[] masks = { 1, 2, 4, 8, 16, 32, 64, 128 }; - int[] bits = new int[8]; + int[] bits = new int[bitCount]; - for (int i = 0; i < 8; i++) { + for (int i = 0; i < bitCount; i++) { bits[i] = bitField & masks[i]; - - channel = channelTypes[i]; - - if (channel != "") { - channelUID = new ChannelUID(getThing().getUID(), channel); - - switch (dscAlarmCode) { - case KeypadLEDState: /* 510 */ - updateChannel(channelUID, bits[i] != 0 ? 1 : 0, ""); - break; - case KeypadLEDFlashState: /* 511 */ - if (bits[i] != 0) { - updateChannel(channelUID, 2, ""); - } - break; - default: - break; - } + ChannelUID channelUID = new ChannelUID(getThing().getUID(), channelTypes[i]); + switch (dscAlarmCode) { + case KeypadLEDState: /* 510 */ + updateChannel(channelUID, bits[i] != 0 ? 1 : 0, ""); + break; + case KeypadLEDFlashState: /* 511 */ + if (bits[i] != 0) { + updateChannel(channelUID, 2, ""); + } + break; + default: + break; } } } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void dscAlarmEventReceived(EventObject event, Thing thing) { if (thing != null) { if (getThing() == thing) { diff --git a/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/PanelThingHandler.java b/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/PanelThingHandler.java index 32ba7a16c..0d1c1ec3b 100644 --- a/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/PanelThingHandler.java +++ b/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/PanelThingHandler.java @@ -257,19 +257,11 @@ public class PanelThingHandler extends DSCAlarmBaseThingHandler { * @param timeStamp */ private void setTimeStampState(String timeStamp) { - int state = 0; - ChannelUID channelUID = new ChannelUID(getThing().getUID(), PANEL_TIME_STAMP); - - boolean isTimeStamp = timeStamp != ""; - - if ((timeStamp == "" && !isTimeStamp) || (timeStamp != "" && isTimeStamp)) { - logger.debug("setTimeStampState(): Already Set: {}", timeStamp); - return; - } else if (timeStamp != "") { - state = 1; + if (timeStamp != null) { + ChannelUID channelUID = new ChannelUID(getThing().getUID(), PANEL_TIME_STAMP); + int state = timeStamp.isEmpty() ? 0 : 1; + updateChannel(channelUID, state, ""); } - - updateChannel(channelUID, state, ""); } /** @@ -391,19 +383,15 @@ public class PanelThingHandler extends DSCAlarmBaseThingHandler { String channel; ChannelUID channelUID = null; + int bitCount = 8; int bitField = Integer.decode("0x" + dscAlarmMessage.getMessageInfo(DSCAlarmMessageInfoType.DATA)); int[] masks = { 1, 2, 4, 8, 16, 32, 64, 128 }; - int[] bits = new int[8]; + int[] bits = new int[bitCount]; - for (int i = 0; i < 8; i++) { + for (int i = 0; i < bitCount; i++) { + channelUID = new ChannelUID(getThing().getUID(), channelTypes[i]); bits[i] = bitField & masks[i]; - - channel = channelTypes[i]; - - if (channel != "") { - channelUID = new ChannelUID(getThing().getUID(), channel); - updateChannel(channelUID, bits[i] != 0 ? 1 : 0, ""); - } + updateChannel(channelUID, bits[i] != 0 ? 1 : 0, ""); } } @@ -436,6 +424,7 @@ public class PanelThingHandler extends DSCAlarmBaseThingHandler { } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void dscAlarmEventReceived(EventObject event, Thing thing) { if (thing != null) { DSCAlarmEvent dscAlarmEvent = (DSCAlarmEvent) event; diff --git a/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/PartitionThingHandler.java b/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/PartitionThingHandler.java index 36cbcc40a..3664ea2a2 100644 --- a/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/PartitionThingHandler.java +++ b/bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/PartitionThingHandler.java @@ -184,6 +184,7 @@ public class PartitionThingHandler extends DSCAlarmBaseThingHandler { } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void dscAlarmEventReceived(EventObject event, Thing thing) { if (thing != null) { if (getThing() == thing) { diff --git a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/DSMRSerialAutoDevice.java b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/DSMRSerialAutoDevice.java index fd757870f..d3faca924 100644 --- a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/DSMRSerialAutoDevice.java +++ b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/DSMRSerialAutoDevice.java @@ -223,6 +223,7 @@ public class DSMRSerialAutoDevice implements DSMRDevice, DSMREventListener { /** * Switches the baudrate on the serial port. */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") private void switchBaudrate() { if (lastSwitchedBaudrateNanos + SWITCHING_BAUDRATE_TIMEOUT_NANOS > System.nanoTime()) { // Ignore switching baudrate if this is called within the timeout after a previous switch. diff --git a/bundles/org.openhab.binding.dwdunwetter/src/main/java/org/openhab/binding/dwdunwetter/internal/dto/SeverityComparator.java b/bundles/org.openhab.binding.dwdunwetter/src/main/java/org/openhab/binding/dwdunwetter/internal/dto/SeverityComparator.java index feb674060..5f2c67e9d 100644 --- a/bundles/org.openhab.binding.dwdunwetter/src/main/java/org/openhab/binding/dwdunwetter/internal/dto/SeverityComparator.java +++ b/bundles/org.openhab.binding.dwdunwetter/src/main/java/org/openhab/binding/dwdunwetter/internal/dto/SeverityComparator.java @@ -13,6 +13,7 @@ package org.openhab.binding.dwdunwetter.internal.dto; import java.util.Comparator; +import java.util.Objects; /** * Comperator to sort a Warning first by Severity, second by the onSet date. @@ -28,7 +29,7 @@ public class SeverityComparator implements Comparator { int result = Integer.compare(o1.getSeverity().getOrder(), o2.getSeverity().getOrder()); if (result == 0) { - if (o1.getOnset() == o2.getOnset()) { + if (Objects.equals(o1.getOnset(), o2.getOnset())) { return 0; } else if (o1.getOnset() == null) { return -1; diff --git a/bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/dto/SelectionDTO.java b/bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/dto/SelectionDTO.java index 0714a8898..cbf5cc97f 100644 --- a/bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/dto/SelectionDTO.java +++ b/bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/dto/SelectionDTO.java @@ -193,27 +193,28 @@ public class SelectionDTO { this.includeRuntime = Boolean.TRUE; this.includeSensors = Boolean.TRUE; - this.includeAudio = selection.includeAudio == Boolean.TRUE ? Boolean.TRUE : includeAudio; - this.includeDevice = selection.includeDevice == Boolean.TRUE ? Boolean.TRUE : includeDevice; - this.includeElectricity = selection.includeElectricity == Boolean.TRUE ? Boolean.TRUE : includeElectricity; - this.includeEnergy = selection.includeEnergy == Boolean.TRUE ? Boolean.TRUE : includeEnergy; - this.includeExtendedRuntime = selection.includeExtendedRuntime == Boolean.TRUE ? Boolean.TRUE + this.includeAudio = Boolean.TRUE.equals(selection.includeAudio) ? Boolean.TRUE : includeAudio; + this.includeDevice = Boolean.TRUE.equals(selection.includeDevice) ? Boolean.TRUE : includeDevice; + this.includeElectricity = Boolean.TRUE.equals(selection.includeElectricity) ? Boolean.TRUE : includeElectricity; + this.includeEnergy = Boolean.TRUE.equals(selection.includeEnergy) ? Boolean.TRUE : includeEnergy; + this.includeExtendedRuntime = Boolean.TRUE.equals(selection.includeExtendedRuntime) ? Boolean.TRUE : includeExtendedRuntime; - this.includeHouseDetails = selection.includeHouseDetails == Boolean.TRUE ? Boolean.TRUE : includeHouseDetails; - this.includeLocation = selection.includeLocation == Boolean.TRUE ? Boolean.TRUE : includeLocation; - this.includeManagement = selection.includeManagement == Boolean.TRUE ? Boolean.TRUE : includeManagement; - this.includeNotificationSettings = selection.includeNotificationSettings == Boolean.TRUE ? Boolean.TRUE + this.includeHouseDetails = Boolean.TRUE.equals(selection.includeHouseDetails) ? Boolean.TRUE + : includeHouseDetails; + this.includeLocation = Boolean.TRUE.equals(selection.includeLocation) ? Boolean.TRUE : includeLocation; + this.includeManagement = Boolean.TRUE.equals(selection.includeManagement) ? Boolean.TRUE : includeManagement; + this.includeNotificationSettings = Boolean.TRUE.equals(selection.includeNotificationSettings) ? Boolean.TRUE : includeNotificationSettings; - this.includeOemCfg = selection.includeOemCfg == Boolean.TRUE ? Boolean.TRUE : includeOemCfg; - this.includePrivacy = selection.includePrivacy == Boolean.TRUE ? Boolean.TRUE : includePrivacy; - this.includeReminders = selection.includeReminders == Boolean.TRUE ? Boolean.TRUE : includeReminders; - this.includeSecuritySettings = selection.includeSecuritySettings == Boolean.TRUE ? Boolean.TRUE + this.includeOemCfg = Boolean.TRUE.equals(selection.includeOemCfg) ? Boolean.TRUE : includeOemCfg; + this.includePrivacy = Boolean.TRUE.equals(selection.includePrivacy) ? Boolean.TRUE : includePrivacy; + this.includeReminders = Boolean.TRUE.equals(selection.includeReminders) ? Boolean.TRUE : includeReminders; + this.includeSecuritySettings = Boolean.TRUE.equals(selection.includeSecuritySettings) ? Boolean.TRUE : includeSecuritySettings; - this.includeSettings = selection.includeSettings == Boolean.TRUE ? Boolean.TRUE : includeSettings; - this.includeTechnician = selection.includeTechnician == Boolean.TRUE ? Boolean.TRUE : includeTechnician; - this.includeUtility = selection.includeUtility == Boolean.TRUE ? Boolean.TRUE : includeUtility; - this.includeVersion = selection.includeVersion == Boolean.TRUE ? Boolean.TRUE : includeVersion; - this.includeWeather = selection.includeWeather == Boolean.TRUE ? Boolean.TRUE : includeWeather; + this.includeSettings = Boolean.TRUE.equals(selection.includeSettings) ? Boolean.TRUE : includeSettings; + this.includeTechnician = Boolean.TRUE.equals(selection.includeTechnician) ? Boolean.TRUE : includeTechnician; + this.includeUtility = Boolean.TRUE.equals(selection.includeUtility) ? Boolean.TRUE : includeUtility; + this.includeVersion = Boolean.TRUE.equals(selection.includeVersion) ? Boolean.TRUE : includeVersion; + this.includeWeather = Boolean.TRUE.equals(selection.includeWeather) ? Boolean.TRUE : includeWeather; return this; } diff --git a/bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/Command.java b/bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/Command.java index a42032a5a..9c587e26a 100644 --- a/bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/Command.java +++ b/bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/Command.java @@ -47,6 +47,7 @@ public class Command implements Delayed { } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public int compareTo(Delayed delayed) { if (delayed == this) { return 0; diff --git a/bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/DelayedCommand.java b/bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/DelayedCommand.java index d921e513b..0b2f448b7 100644 --- a/bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/DelayedCommand.java +++ b/bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/DelayedCommand.java @@ -30,6 +30,7 @@ public class DelayedCommand extends Command { } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public int compareTo(Delayed delayed) { if (delayed == this) { return 0; diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_3F/A5_3F_7F_Universal.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_3F/A5_3F_7F_Universal.java index da1150c18..8911b6666 100644 --- a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_3F/A5_3F_7F_Universal.java +++ b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_3F/A5_3F_7F_Universal.java @@ -49,7 +49,7 @@ public class A5_3F_7F_Universal extends _4BSMessage { String c = Transformation.transform(transformationInfo.transformationType, transformationInfo.transformationFunction, command.toString()); - if (c != null && c != command.toString()) { + if (c != null && !c.equals(command.toString())) { setData(HexUtils.hexToBytes(c)); } diff --git a/bundles/org.openhab.binding.gce/src/main/java/org/openhab/binding/gce/internal/handler/Ipx800v3Handler.java b/bundles/org.openhab.binding.gce/src/main/java/org/openhab/binding/gce/internal/handler/Ipx800v3Handler.java index 510345631..04d39d086 100644 --- a/bundles/org.openhab.binding.gce/src/main/java/org/openhab/binding/gce/internal/handler/Ipx800v3Handler.java +++ b/bundles/org.openhab.binding.gce/src/main/java/org/openhab/binding/gce/internal/handler/Ipx800v3Handler.java @@ -97,6 +97,7 @@ public class Ipx800v3Handler extends BaseThingHandler implements Ipx800EventList } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void run() { PortData currentData = portDatas.get(port); if (currentData != null && currentData.getValue() == 1 && currentData.getTimestamp() == referenceTime) { diff --git a/bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/message/LocationMessage.java b/bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/message/LocationMessage.java index 1b23e5718..5e78b88da 100644 --- a/bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/message/LocationMessage.java +++ b/bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/message/LocationMessage.java @@ -103,7 +103,7 @@ public class LocationMessage { * @return Conversion result */ public State getTrackerLocation() { - if (latitude != BigDecimal.ZERO && longitude != BigDecimal.ZERO) { + if (!BigDecimal.ZERO.equals(latitude) && !BigDecimal.ZERO.equals(longitude)) { return new PointType(new DecimalType(latitude), new DecimalType(longitude)); } return UnDefType.UNDEF; diff --git a/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeAirDevice.java b/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeAirDevice.java index 13cc61ca8..52657ed61 100644 --- a/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeAirDevice.java +++ b/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeAirDevice.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -277,8 +278,8 @@ public class GreeAirDevice { // If commanding Fahrenheit set halfStep to 1 or 0 to tell the A/C which F integer // temperature to use as celsius alone is ambigious double newVal = temp.doubleValue(); - int CorF = temp.getUnit() == SIUnits.CELSIUS ? TEMP_UNIT_CELSIUS : TEMP_UNIT_FAHRENHEIT; // 0=Celsius, - // 1=Fahrenheit + int CorF = SIUnits.CELSIUS.equals(temp.getUnit()) ? TEMP_UNIT_CELSIUS : TEMP_UNIT_FAHRENHEIT; // 0=Celsius, + // 1=Fahrenheit if (((CorF == TEMP_UNIT_CELSIUS) && (newVal < TEMP_MIN_C || newVal > TEMP_MAX_C)) || ((CorF == TEMP_UNIT_FAHRENHEIT) && (newVal < TEMP_MIN_F || newVal > TEMP_MAX_F))) { throw new IllegalArgumentException("Temp Value out of Range"); @@ -404,7 +405,7 @@ public class GreeAirDevice { } // Finally Compare the values - return currvalList.get(currvalueArrayposition) != prevvalList.get(prevvalueArrayposition); + return !Objects.equals(currvalList.get(currvalueArrayposition), prevvalList.get(prevvalueArrayposition)); } protected void executeCommand(DatagramSocket clientSocket, Map parameters) throws GreeException { diff --git a/bundles/org.openhab.binding.haywardomnilogic/src/main/java/org/openhab/binding/haywardomnilogic/internal/discovery/HaywardDiscoveryService.java b/bundles/org.openhab.binding.haywardomnilogic/src/main/java/org/openhab/binding/haywardomnilogic/internal/discovery/HaywardDiscoveryService.java index 93fe883f0..a6bea2b11 100644 --- a/bundles/org.openhab.binding.haywardomnilogic/src/main/java/org/openhab/binding/haywardomnilogic/internal/discovery/HaywardDiscoveryService.java +++ b/bundles/org.openhab.binding.haywardomnilogic/src/main/java/org/openhab/binding/haywardomnilogic/internal/discovery/HaywardDiscoveryService.java @@ -170,7 +170,7 @@ public class HaywardDiscoveryService extends AbstractDiscoveryService implements List names; // Set Virtual Heater Name - if (thingType == HaywardBindingConstants.THING_TYPE_VIRTUALHEATER) { + if (HaywardBindingConstants.THING_TYPE_VIRTUALHEATER.equals(thingType)) { names = new ArrayList<>(systemIDs); Collections.fill(names, "Heater"); } else { diff --git a/bundles/org.openhab.binding.heliosventilation/src/main/java/org/openhab/binding/heliosventilation/internal/HeliosVentilationDataPoint.java b/bundles/org.openhab.binding.heliosventilation/src/main/java/org/openhab/binding/heliosventilation/internal/HeliosVentilationDataPoint.java index 247ab2652..025289083 100644 --- a/bundles/org.openhab.binding.heliosventilation/src/main/java/org/openhab/binding/heliosventilation/internal/HeliosVentilationDataPoint.java +++ b/bundles/org.openhab.binding.heliosventilation/src/main/java/org/openhab/binding/heliosventilation/internal/HeliosVentilationDataPoint.java @@ -309,6 +309,7 @@ public class HeliosVentilationDataPoint { * * @param next is the sister datapoint */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void append(HeliosVentilationDataPoint next) { HeliosVentilationDataPoint existing = this.next; if (this == next) { diff --git a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/converter/type/OnOffTypeConverter.java b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/converter/type/OnOffTypeConverter.java index 579e72293..7dce57520 100644 --- a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/converter/type/OnOffTypeConverter.java +++ b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/converter/type/OnOffTypeConverter.java @@ -42,7 +42,7 @@ public class OnOffTypeConverter extends AbstractTypeConverter { @Override protected OnOffType fromBinding(HmDatapoint dp) throws ConverterException { - return (((Boolean) dp.getValue()) == Boolean.FALSE) != isInvert(dp) ? OnOffType.OFF : OnOffType.ON; + return Boolean.FALSE.equals(dp.getValue()) != isInvert(dp) ? OnOffType.OFF : OnOffType.ON; } /** diff --git a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/converter/type/OpenClosedTypeConverter.java b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/converter/type/OpenClosedTypeConverter.java index ebd4af835..55680b2f2 100644 --- a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/converter/type/OpenClosedTypeConverter.java +++ b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/converter/type/OpenClosedTypeConverter.java @@ -42,8 +42,7 @@ public class OpenClosedTypeConverter extends AbstractTypeConverter { Double number = (type.doubleValue() / 100) * maxValue; if (MetadataUtils.isRollerShutter(dp)) { - if (type == PercentType.HUNDRED) { // means DOWN + if (PercentType.HUNDRED.equals(type)) { // means DOWN return dp.getMinValue().doubleValue(); - } else if (type == PercentType.ZERO) { // means UP + } else if (PercentType.ZERO.equals(type)) { // means UP return maxValue; } return maxValue - number; diff --git a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/misc/MiscUtils.java b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/misc/MiscUtils.java index d41aaad9e..9621bf39d 100644 --- a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/misc/MiscUtils.java +++ b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/misc/MiscUtils.java @@ -41,14 +41,14 @@ public class MiscUtils { * Returns true, if the value is not null and true. */ public static boolean isTrueValue(Object value) { - return value != null && value == Boolean.TRUE; + return Boolean.TRUE.equals(value); } /** * Returns true, if the value is not null and false. */ public static boolean isFalseValue(Object value) { - return value != null && value == Boolean.FALSE; + return Boolean.FALSE.equals(value); } /** diff --git a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/type/MetadataUtils.java b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/type/MetadataUtils.java index 664c9508f..719f03442 100644 --- a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/type/MetadataUtils.java +++ b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/type/MetadataUtils.java @@ -175,7 +175,7 @@ public class MetadataUtils { if ("%%".equals(unit)) { return "%d %%"; } - if (unit != null && unit != "") { + if (unit != null && !unit.isEmpty()) { String pattern = getPattern(dp); if (pattern != null) { return String.format("%s %s", pattern, "%unit%"); diff --git a/bundles/org.openhab.binding.iaqualink/src/main/java/org/openhab/binding/iaqualink/internal/handler/IAqualinkHandler.java b/bundles/org.openhab.binding.iaqualink/src/main/java/org/openhab/binding/iaqualink/internal/handler/IAqualinkHandler.java index 50a4e189b..9a763b7f8 100644 --- a/bundles/org.openhab.binding.iaqualink/src/main/java/org/openhab/binding/iaqualink/internal/handler/IAqualinkHandler.java +++ b/bundles/org.openhab.binding.iaqualink/src/main/java/org/openhab/binding/iaqualink/internal/handler/IAqualinkHandler.java @@ -206,7 +206,9 @@ public class IAqualinkHandler extends BaseThingHandler { Optional optional = Arrays.stream(auxs).filter(o -> o.getName().equals(channelName)) .findFirst(); if (optional.isPresent()) { - if (toState(channelName, "Switch", optional.get().getState()) != command) { + OnOffType onOffCommand = (OnOffType) command; + State currentState = toState(channelName, "Switch", optional.get().getState()); + if (!currentState.equals(onOffCommand)) { client.auxSetCommand(serialNumber, sessionId, channelName); } } @@ -225,20 +227,23 @@ public class IAqualinkHandler extends BaseThingHandler { } } } else if (command instanceof OnOffType) { + OnOffType onOffCommand = (OnOffType) command; // these are toggle commands and require we have the current state to turn on/off if (channelName.startsWith("onetouch_")) { OneTouch[] ota = client.getOneTouch(serialNumber, sessionId); Optional optional = Arrays.stream(ota).filter(o -> o.getName().equals(channelName)) .findFirst(); if (optional.isPresent()) { - if (toState(channelName, "Switch", optional.get().getState()) != command) { + State currentState = toState(channelName, "Switch", optional.get().getState()); + if (!currentState.equals(onOffCommand)) { logger.debug("Sending command {} to {}", command, channelName); client.oneTouchSetCommand(serialNumber, sessionId, channelName); } } } else if (channelName.endsWith("heater") || channelName.endsWith("pump")) { String value = client.getHome(serialNumber, sessionId).getSerializedMap().get(channelName); - if (toState(channelName, "Switch", value) != command) { + State currentState = toState(channelName, "Switch", value); + if (!currentState.equals(onOffCommand)) { logger.debug("Sending command {} to {}", command, channelName); client.homeScreenSetCommand(serialNumber, sessionId, channelName); } diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/device/Device.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/device/Device.java index 1f658dca2..ef230a448 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/device/Device.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/device/Device.java @@ -190,7 +190,7 @@ public class Device { * @return */ public boolean hasSerialNumber() { - return (serialnumber != null && serialnumber != ""); + return serialnumber != null && !serialnumber.isEmpty(); } /** diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java index 00abaa6ac..c60e6d9cb 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java @@ -731,7 +731,7 @@ public abstract class CommandHandler { int ilevel = dc * intFactor; byte level = (byte) (ilevel > 255 ? 0xFF : ((ilevel < 0) ? 0 : ilevel)); String vfield = getStringParameter("value", ""); - if (vfield == "") { + if (vfield == null || vfield.isEmpty()) { logger.warn("{} has no value field specified", nm()); } // diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageDispatcher.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageDispatcher.java index 96810f396..419de6311 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageDispatcher.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageDispatcher.java @@ -107,6 +107,7 @@ public abstract class MessageDispatcher { * @param msg * @return true; */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") boolean isMyDirectAck(Msg msg) { return msg.isAckOfDirect() && (feature.getQueryStatus() == DeviceFeature.QueryStatus.QUERY_PENDING) && feature.getDevice().getFeatureQueried() == feature; diff --git a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java index f88f66909..d0e90dd75 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java +++ b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java @@ -359,6 +359,7 @@ public class IpCameraHandler extends BaseThingHandler { } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void userEventTriggered(@Nullable ChannelHandlerContext ctx, @Nullable Object evt) throws Exception { if (ctx == null) { return; @@ -700,6 +701,7 @@ public class IpCameraHandler extends BaseThingHandler { * open large amounts of channels. This may help to keep it under control and WARN the user every 8 seconds this is * still occurring. */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") private void cleanChannels() { for (Channel channel : openChannels) { boolean oldChannel = true; diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/JeeLinkHandler.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/JeeLinkHandler.java index 5cf1936ef..9841f3519 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/JeeLinkHandler.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/JeeLinkHandler.java @@ -170,7 +170,7 @@ public class JeeLinkHandler extends BaseBridgeHandler implements BridgeHandler, // this is the first handler for this reading class => also setup converter readingClassHandlerMap.put(h.getReadingClass(), handlers); - if (SensorDefinition.ALL_TYPE == h.getSensorType()) { + if (SensorDefinition.ALL_TYPE.equals(h.getSensorType())) { converters.addAll(SensorDefinition.getDiscoveryConverters()); } else { JeeLinkReadingConverter c = SensorDefinition.getConverter(h.getSensorType()); @@ -200,7 +200,7 @@ public class JeeLinkHandler extends BaseBridgeHandler implements BridgeHandler, // this was the last handler for this reading class => also remove converter readingClassHandlerMap.remove(h.getReadingClass()); - if (SensorDefinition.ALL_TYPE == h.getSensorType()) { + if (SensorDefinition.ALL_TYPE.equals(h.getSensorType())) { converters.removeAll(SensorDefinition.getDiscoveryConverters()); } else { JeeLinkReadingConverter c = SensorDefinition.getConverter(h.getSensorType()); diff --git a/bundles/org.openhab.binding.kostalinverter/src/main/java/org/openhab/binding/kostalinverter/internal/secondgeneration/SecondGenerationConfigurationHandler.java b/bundles/org.openhab.binding.kostalinverter/src/main/java/org/openhab/binding/kostalinverter/internal/secondgeneration/SecondGenerationConfigurationHandler.java index d04505655..357cebaf5 100644 --- a/bundles/org.openhab.binding.kostalinverter/src/main/java/org/openhab/binding/kostalinverter/internal/secondgeneration/SecondGenerationConfigurationHandler.java +++ b/bundles/org.openhab.binding.kostalinverter/src/main/java/org/openhab/binding/kostalinverter/internal/secondgeneration/SecondGenerationConfigurationHandler.java @@ -135,7 +135,7 @@ public class SecondGenerationConfigurationHandler { if (size > 0) { extractSessionId = extractJsonArraySessionId.get(size - 1).getAsJsonObject().get("sessionId").getAsString(); } - if (extractSessionId == "0") { + if ("0".equals(extractSessionId)) { sessionIdLogger.debug(" Login Post Json Reponse not OK! , inverter answered with sessionId like: {}", extractSessionId); } @@ -152,7 +152,7 @@ public class SecondGenerationConfigurationHandler { if (size > 0) { extractCode = extractJsonArrayCode.get(size - 1).getAsJsonObject().get("code").getAsString(); } - if (extractCode != "0") { + if (!"0".equals(extractCode)) { codeLogger.debug(" Login Post Json Reponse not OK! , inverter answered with status code like: {}", extractCode); } diff --git a/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleDiscoveryService.java b/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleDiscoveryService.java index bc3f0d646..2ea0a43f7 100644 --- a/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleDiscoveryService.java +++ b/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleDiscoveryService.java @@ -99,6 +99,7 @@ public class LcnModuleDiscoveryService extends AbstractDiscoveryService } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") protected void startScan() { synchronized (this) { PckGatewayHandler localBridgeHandler = bridgeHandler; diff --git a/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleRvarSetpointSubHandler.java b/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleRvarSetpointSubHandler.java index 19370b2c5..ba059c41e 100644 --- a/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleRvarSetpointSubHandler.java +++ b/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleRvarSetpointSubHandler.java @@ -54,6 +54,7 @@ public class LcnModuleRvarSetpointSubHandler extends AbstractLcnModuleVariableSu } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void handleStatusMessage(Matcher matcher) throws LcnException { Variable variable; if (matcher.pattern() == PATTERN) { diff --git a/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleVariableSubHandler.java b/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleVariableSubHandler.java index 5a9e77d4a..ed389f11b 100644 --- a/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleVariableSubHandler.java +++ b/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleVariableSubHandler.java @@ -66,6 +66,7 @@ public class LcnModuleVariableSubHandler extends AbstractLcnModuleVariableSubHan } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void handleStatusMessage(Matcher matcher) throws LcnException { Variable variable; if (matcher.pattern() == PATTERN) { diff --git a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/dto/Effect.java b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/dto/Effect.java index 2490e2263..7e4e9dc0b 100644 --- a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/dto/Effect.java +++ b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/dto/Effect.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.lifx.internal.dto; +import java.util.Arrays; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.lifx.internal.LifxBindingConstants; @@ -153,7 +155,7 @@ public class Effect { } Effect n = (Effect) o; return n.getType().equals(this.getType()) && n.duration.equals(this.duration) && n.speed.equals(this.speed) - && n.palette == this.palette; + && Arrays.equals(n.palette, this.palette); } @Override diff --git a/bundles/org.openhab.binding.luxtronikheatpump/src/main/java/org/openhab/binding/luxtronikheatpump/internal/ChannelUpdaterJob.java b/bundles/org.openhab.binding.luxtronikheatpump/src/main/java/org/openhab/binding/luxtronikheatpump/internal/ChannelUpdaterJob.java index 7bca5ae90..9af167988 100644 --- a/bundles/org.openhab.binding.luxtronikheatpump/src/main/java/org/openhab/binding/luxtronikheatpump/internal/ChannelUpdaterJob.java +++ b/bundles/org.openhab.binding.luxtronikheatpump/src/main/java/org/openhab/binding/luxtronikheatpump/internal/ChannelUpdaterJob.java @@ -134,14 +134,14 @@ public class ChannelUpdaterJob implements SchedulerRunnable, Runnable { if (unit == null) { return new DecimalType(rawValue); } - if (unit == SIUnits.CELSIUS || unit == Units.KELVIN || unit == Units.KILOWATT_HOUR || unit == Units.PERCENT - || unit == Units.HOUR) { + if (SIUnits.CELSIUS.equals(unit) || Units.KELVIN.equals(unit) || Units.KILOWATT_HOUR.equals(unit) + || Units.PERCENT.equals(unit) || Units.HOUR.equals(unit)) { return new QuantityType<>((double) rawValue / 10, unit); - } else if (unit == Units.HERTZ || unit == Units.SECOND) { + } else if (Units.HERTZ.equals(unit) || Units.SECOND.equals(unit)) { return new QuantityType<>((double) rawValue, unit); - } else if (unit == Units.LITRE_PER_MINUTE) { + } else if (Units.LITRE_PER_MINUTE.equals(unit)) { return new QuantityType<>((double) rawValue / 60, unit); - } else if (unit == Units.BAR || unit == Units.VOLT) { + } else if (Units.BAR.equals(unit) || Units.VOLT.equals(unit)) { return new QuantityType<>((double) rawValue / 100, unit); } @@ -222,7 +222,7 @@ public class ChannelUpdaterJob implements SchedulerRunnable, Runnable { var longState = String.format("%s - %s %s - %s", state, getStateTranslation("menuStateLine2", row2), formatHours(time), getStateTranslation("menuStateLine3", row3)); - handleEventType((State) new StringType(longState), HeatpumpChannel.CHANNEL_HEATPUMP_STATUS); + handleEventType(new StringType(longState), HeatpumpChannel.CHANNEL_HEATPUMP_STATUS); } private void updateProperties(Integer[] heatpumpValues) { diff --git a/bundles/org.openhab.binding.modbus.helioseasycontrols/src/main/java/org/openhab/binding/modbus/helioseasycontrols/internal/HeliosEasyControlsHandler.java b/bundles/org.openhab.binding.modbus.helioseasycontrols/src/main/java/org/openhab/binding/modbus/helioseasycontrols/internal/HeliosEasyControlsHandler.java index dc1c9aa52..017f7f962 100644 --- a/bundles/org.openhab.binding.modbus.helioseasycontrols/src/main/java/org/openhab/binding/modbus/helioseasycontrols/internal/HeliosEasyControlsHandler.java +++ b/bundles/org.openhab.binding.modbus.helioseasycontrols/src/main/java/org/openhab/binding/modbus/helioseasycontrols/internal/HeliosEasyControlsHandler.java @@ -854,8 +854,8 @@ public class HeliosEasyControlsHandler extends BaseThingHandler { } switch (itemType) { case "Number": - if (((variableType.equals(HeliosVariable.TYPE_INTEGER)) - || (variableType == HeliosVariable.TYPE_FLOAT)) && (!value.equals("-"))) { + if (((HeliosVariable.TYPE_INTEGER.equals(variableType)) + || (HeliosVariable.TYPE_FLOAT.equals(variableType))) && (!value.equals("-"))) { State state = null; if (v.getUnit() == null) { state = DecimalType.valueOf(value); diff --git a/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/Property.java b/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/Property.java index bf07a6c83..1abca7c84 100644 --- a/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/Property.java +++ b/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/Property.java @@ -177,7 +177,7 @@ public class Property implements AttributeChanged { Value value; Boolean isDecimal = null; - if (attributes.name == "") { + if (attributes.name.isEmpty()) { attributes.name = propertyID; } diff --git a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/SystemBrokerHandler.java b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/SystemBrokerHandler.java index 83b1012d9..8a37c1705 100644 --- a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/SystemBrokerHandler.java +++ b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/SystemBrokerHandler.java @@ -93,6 +93,7 @@ public class SystemBrokerHandler extends AbstractBrokerHandler implements MqttSe * is no connection established yet. */ @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void brokerAdded(String connectionName, MqttBrokerConnection addedConnection) { if (!connectionName.equals(brokerID) || connection == addedConnection) { return; diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/thermostat/NATherm1Handler.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/thermostat/NATherm1Handler.java index 2ee500127..01987073d 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/thermostat/NATherm1Handler.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/thermostat/NATherm1Handler.java @@ -128,7 +128,7 @@ public class NATherm1Handler extends NetatmoModuleHandler { String currentPlanning = "-"; if (thermostat.isPresent()) { for (NAThermProgram program : nonNullList(thermostat.get().getThermProgramList())) { - if (program.isSelected() == Boolean.TRUE) { + if (Boolean.TRUE.equals(program.isSelected())) { currentPlanning = program.getProgramId(); } } diff --git a/bundles/org.openhab.binding.oceanic/src/main/java/org/openhab/binding/oceanic/internal/handler/OceanicThingHandler.java b/bundles/org.openhab.binding.oceanic/src/main/java/org/openhab/binding/oceanic/internal/handler/OceanicThingHandler.java index af944440e..3e0b24efd 100644 --- a/bundles/org.openhab.binding.oceanic/src/main/java/org/openhab/binding/oceanic/internal/handler/OceanicThingHandler.java +++ b/bundles/org.openhab.binding.oceanic/src/main/java/org/openhab/binding/oceanic/internal/handler/OceanicThingHandler.java @@ -69,7 +69,7 @@ public abstract class OceanicThingHandler extends BaseThingHandler { if (aChannel.getUID().equals(theChannelUID) && selector.getTypeValue() == OceanicChannelSelector.ValueSelectorType.GET) { String response = requestResponse(selector.name()); - if (response != null && response != "") { + if (response != null && !response.isEmpty()) { if (selector.isProperty()) { logger.debug("Updating the property '{}' with value '{}'", selector.toString(), selector.convertValue(response)); diff --git a/bundles/org.openhab.binding.openthermgateway/src/main/java/org/openhab/binding/openthermgateway/handler/OpenThermGatewayHandler.java b/bundles/org.openhab.binding.openthermgateway/src/main/java/org/openhab/binding/openthermgateway/handler/OpenThermGatewayHandler.java index b515d2fbf..733af5344 100644 --- a/bundles/org.openhab.binding.openthermgateway/src/main/java/org/openhab/binding/openthermgateway/handler/OpenThermGatewayHandler.java +++ b/bundles/org.openhab.binding.openthermgateway/src/main/java/org/openhab/binding/openthermgateway/handler/OpenThermGatewayHandler.java @@ -111,14 +111,14 @@ public class OpenThermGatewayHandler extends BaseThingHandler implements OpenThe if (conn != null && conn.isConnected()) { conn.sendCommand(gatewayCommand); - if (code == GatewayCommandCode.ControlSetpoint) { + if (GatewayCommandCode.ControlSetpoint.equals(code)) { if (gatewayCommand.getMessage().equals("0.0")) { updateState(OpenThermGatewayBindingConstants.CHANNEL_OVERRIDE_CENTRAL_HEATING_WATER_SETPOINT, UnDefType.UNDEF); } updateState(OpenThermGatewayBindingConstants.CHANNEL_OVERRIDE_CENTRAL_HEATING_ENABLED, OnOffType.from(!gatewayCommand.getMessage().equals("0.0"))); - } else if (code == GatewayCommandCode.ControlSetpoint2) { + } else if (GatewayCommandCode.ControlSetpoint2.equals(code)) { if (gatewayCommand.getMessage().equals("0.0")) { updateState(OpenThermGatewayBindingConstants.CHANNEL_OVERRIDE_CENTRAL_HEATING2_WATER_SETPOINT, UnDefType.UNDEF); diff --git a/bundles/org.openhab.binding.openuv/src/main/java/org/openhab/binding/openuv/internal/handler/OpenUVReportHandler.java b/bundles/org.openhab.binding.openuv/src/main/java/org/openhab/binding/openuv/internal/handler/OpenUVReportHandler.java index 7a8488ebc..713515573 100644 --- a/bundles/org.openhab.binding.openuv/src/main/java/org/openhab/binding/openuv/internal/handler/OpenUVReportHandler.java +++ b/bundles/org.openhab.binding.openuv/src/main/java/org/openhab/binding/openuv/internal/handler/OpenUVReportHandler.java @@ -181,7 +181,7 @@ public class OpenUVReportHandler extends BaseThingHandler { }); } else if (ELEVATION.equals(channelUID.getId()) && command instanceof QuantityType) { QuantityType qtty = (QuantityType) command; - if (qtty.getUnit() == Units.DEGREE_ANGLE) { + if (Units.DEGREE_ANGLE.equals(qtty.getUnit())) { suspendUpdates = qtty.doubleValue() < 0; } else { logger.info("The OpenUV Report handles Sun Elevation of Number:Angle type, {} does not fit.", command); diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java index e92e68483..e6857d837 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java @@ -176,7 +176,7 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService } String ownId = bridgeHandler.ownIdFromWhoWhere(deviceWho, where); - if (thingTypeUID == OpenWebNetBindingConstants.THING_TYPE_BUS_ON_OFF_SWITCH) { + if (OpenWebNetBindingConstants.THING_TYPE_BUS_ON_OFF_SWITCH.equals(thingTypeUID)) { if (bridgeHandler.getRegisteredDevice(ownId) != null) { logger.debug("dimmer/switch with WHERE={} already registered, skipping this discovery result", where); return; @@ -204,7 +204,7 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService Map properties = new HashMap<>(2); properties.put(OpenWebNetBindingConstants.CONFIG_PROPERTY_WHERE, whereConfig); properties.put(OpenWebNetBindingConstants.PROPERTY_OWNID, ownId); - if (thingTypeUID == OpenWebNetBindingConstants.THING_TYPE_GENERIC_DEVICE) { + if (OpenWebNetBindingConstants.THING_TYPE_GENERIC_DEVICE.equals(thingTypeUID)) { thingLabel = thingLabel + " (WHO=" + deviceWho + ", WHERE=" + whereConfig + ")"; } else { thingLabel = thingLabel + " (WHERE=" + whereConfig + ")"; diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetBridgeHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetBridgeHandler.java index c2e21d82a..7908f63d8 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetBridgeHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetBridgeHandler.java @@ -17,6 +17,7 @@ import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants import java.util.Collection; import java.util.Collections; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; @@ -458,13 +459,13 @@ public class OpenWebNetBridgeHandler extends ConfigStatusBridgeHandler implement logger.info("---- CONNECTED to BUS gateway bridge '{}' ({}:{})", thing.getUID(), ((BUSGateway) gw).getHost(), ((BUSGateway) gw).getPort()); // update serial number property (with MAC address) - if (properties.get(PROPERTY_SERIAL_NO) != gw.getMACAddr().toUpperCase()) { + if (!Objects.equals(properties.get(PROPERTY_SERIAL_NO), gw.getMACAddr().toUpperCase())) { properties.put(PROPERTY_SERIAL_NO, gw.getMACAddr().toUpperCase()); propertiesChanged = true; logger.debug("updated property gw serialNumber: {}", properties.get(PROPERTY_SERIAL_NO)); } } - if (properties.get(PROPERTY_FIRMWARE_VERSION) != gw.getFirmwareVersion()) { + if (!Objects.equals(properties.get(PROPERTY_FIRMWARE_VERSION), gw.getFirmwareVersion())) { properties.put(PROPERTY_FIRMWARE_VERSION, gw.getFirmwareVersion()); propertiesChanged = true; logger.debug("updated property gw firmware version: {}", properties.get(PROPERTY_FIRMWARE_VERSION)); diff --git a/bundles/org.openhab.binding.pentair/src/main/java/org/openhab/binding/pentair/internal/handler/PentairEasyTouchHandler.java b/bundles/org.openhab.binding.pentair/src/main/java/org/openhab/binding/pentair/internal/handler/PentairEasyTouchHandler.java index cf25382de..360f3a997 100644 --- a/bundles/org.openhab.binding.pentair/src/main/java/org/openhab/binding/pentair/internal/handler/PentairEasyTouchHandler.java +++ b/bundles/org.openhab.binding.pentair/src/main/java/org/openhab/binding/pentair/internal/handler/PentairEasyTouchHandler.java @@ -16,6 +16,7 @@ import static org.openhab.binding.pentair.internal.PentairBindingConstants.*; import java.math.BigDecimal; import java.util.List; +import java.util.Objects; import org.openhab.binding.pentair.internal.PentairBindingConstants; import org.openhab.binding.pentair.internal.PentairPacket; @@ -454,7 +455,7 @@ public class PentairEasyTouchHandler extends PentairBaseThingHandler { } break; case EASYTOUCH_SPAHEATMODESTR: - if (phsp == null || (phsp.spaheatmodestr != phspcur.spaheatmodestr)) { + if (phsp == null || (!Objects.equals(phsp.spaheatmodestr, phspcur.spaheatmodestr))) { if (phspcur.spaheatmodestr != null) { updateState(channel, new StringType(phspcur.spaheatmodestr)); } @@ -466,7 +467,7 @@ public class PentairEasyTouchHandler extends PentairBaseThingHandler { } break; case EASYTOUCH_POOLHEATMODESTR: - if (phsp == null || (phsp.poolheatmodestr != phspcur.poolheatmodestr)) { + if (phsp == null || (!Objects.equals(phsp.poolheatmodestr, phspcur.poolheatmodestr))) { if (phspcur.poolheatmodestr != null) { updateState(channel, new StringType(phspcur.poolheatmodestr)); } diff --git a/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/handler/PLCBridgeHandler.java b/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/handler/PLCBridgeHandler.java index 795743625..2d2e8941c 100644 --- a/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/handler/PLCBridgeHandler.java +++ b/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/handler/PLCBridgeHandler.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -177,7 +178,7 @@ public class PLCBridgeHandler extends BaseBridgeHandler { for (Integer key : states.keySet()) { String message = states.get(buffer[0] & key.intValue()); synchronized (oldValues) { - if ((message != null) && (oldValues.get(channelUID) != message)) { + if (message != null && !Objects.equals(oldValues.get(channelUID), message)) { updateState(channelUID, new StringType(message)); oldValues.put(channelUID, message); } @@ -187,7 +188,7 @@ public class PLCBridgeHandler extends BaseBridgeHandler { } else if (DAY_OF_WEEK_CHANNEL.equals(channelId)) { String value = DAY_OF_WEEK.get(Integer.valueOf(buffer[0])); synchronized (oldValues) { - if ((value != null) && (oldValues.get(channelUID) != value)) { + if (value != null && !Objects.equals(oldValues.get(channelUID), value)) { updateState(channelUID, new StringType(value)); oldValues.put(channelUID, value); } diff --git a/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/AbstractPlugwiseThingHandler.java b/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/AbstractPlugwiseThingHandler.java index eaf14a334..cce19a28d 100644 --- a/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/AbstractPlugwiseThingHandler.java +++ b/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/AbstractPlugwiseThingHandler.java @@ -287,7 +287,7 @@ public abstract class AbstractPlugwiseThingHandler extends BaseThingHandler impl protected void updateTask(PlugwiseDeviceTask task) { if (task.shouldBeScheduled()) { - if (!task.isScheduled() || task.getConfiguredInterval() != task.getInterval()) { + if (!task.isScheduled() || !task.getConfiguredInterval().equals(task.getInterval())) { if (task.isScheduled()) { task.stop(); } diff --git a/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/PlugwiseStickHandler.java b/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/PlugwiseStickHandler.java index 2a8e14dec..62c30d20c 100644 --- a/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/PlugwiseStickHandler.java +++ b/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/PlugwiseStickHandler.java @@ -262,7 +262,7 @@ public class PlugwiseStickHandler extends BaseBridgeHandler implements PlugwiseM protected void updateTask(PlugwiseDeviceTask task) { if (task.shouldBeScheduled()) { - if (!task.isScheduled() || task.getConfiguredInterval() != task.getInterval()) { + if (!task.isScheduled() || !task.getConfiguredInterval().equals(task.getInterval())) { if (task.isScheduled()) { task.stop(); } diff --git a/bundles/org.openhab.binding.qbus/src/main/java/org/openhab/binding/qbus/internal/handler/QbusDimmerHandler.java b/bundles/org.openhab.binding.qbus/src/main/java/org/openhab/binding/qbus/internal/handler/QbusDimmerHandler.java index fc91c6a3f..52520ffbb 100644 --- a/bundles/org.openhab.binding.qbus/src/main/java/org/openhab/binding/qbus/internal/handler/QbusDimmerHandler.java +++ b/bundles/org.openhab.binding.qbus/src/main/java/org/openhab/binding/qbus/internal/handler/QbusDimmerHandler.java @@ -244,7 +244,7 @@ public class QbusDimmerHandler extends QbusGlobalHandler { } } else if (command instanceof PercentType) { int percentToInt = ((PercentType) command).intValue(); - if (command == PercentType.ZERO) { + if (PercentType.ZERO.equals(command)) { qDimmer.execute(0, snr); } else { qDimmer.execute(percentToInt, snr); diff --git a/bundles/org.openhab.binding.qbus/src/main/java/org/openhab/binding/qbus/internal/handler/QbusRolHandler.java b/bundles/org.openhab.binding.qbus/src/main/java/org/openhab/binding/qbus/internal/handler/QbusRolHandler.java index 0a1a532f1..8f30e6734 100644 --- a/bundles/org.openhab.binding.qbus/src/main/java/org/openhab/binding/qbus/internal/handler/QbusRolHandler.java +++ b/bundles/org.openhab.binding.qbus/src/main/java/org/openhab/binding/qbus/internal/handler/QbusRolHandler.java @@ -218,7 +218,7 @@ public class QbusRolHandler extends QbusGlobalHandler { } else if (command instanceof PercentType) { PercentType p = (PercentType) command; int pp = p.intValue(); - if (p == PercentType.ZERO) { + if (PercentType.ZERO.equals(p)) { qRol.execute(0, snr); } else { qRol.execute(pp, snr); @@ -264,7 +264,7 @@ public class QbusRolHandler extends QbusGlobalHandler { } } else if (command instanceof PercentType) { int percentToInt = ((PercentType) command).intValue(); - if (command == PercentType.ZERO) { + if (PercentType.ZERO.equals(command)) { qRol.executeSlats(0, snr); } else { qRol.executeSlats(percentToInt, snr); diff --git a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelOutputHandler.java b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelOutputHandler.java index 6600b99eb..522e3d621 100644 --- a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelOutputHandler.java +++ b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelOutputHandler.java @@ -61,6 +61,7 @@ public class SatelOutputHandler extends WirelessChannelsHandler { } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") protected StateType getStateType(String channelId) { StateType result = super.getStateType(channelId); if (result == StateType.NONE) { diff --git a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelStateThingHandler.java b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelStateThingHandler.java index 704b4452c..04c50d915 100644 --- a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelStateThingHandler.java +++ b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelStateThingHandler.java @@ -90,6 +90,7 @@ public abstract class SatelStateThingHandler extends SatelThingHandler { } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") public void incomingEvent(IntegraStateEvent event) { logger.trace("Handling incoming event: {}", event); // update thing's state unless it should accept commands only @@ -162,6 +163,7 @@ public abstract class SatelStateThingHandler extends SatelThingHandler { * @param event list of state changes since last refresh * @return collection of {@link IntegraStateCommand} */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") protected Collection getRefreshCommands(NewStatesEvent event) { final boolean hasExtPayload = getBridgeHandler().getIntegraType().hasExtPayload(); final Collection result = new LinkedList<>(); diff --git a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelZoneHandler.java b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelZoneHandler.java index 88c941eee..c5f42f4f1 100644 --- a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelZoneHandler.java +++ b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelZoneHandler.java @@ -75,6 +75,7 @@ public class SatelZoneHandler extends WirelessChannelsHandler { } @Override + @SuppressWarnings("PMD.CompareObjectsWithEquals") protected StateType getStateType(String channelId) { StateType result = super.getStateType(channelId); if (result == StateType.NONE) { diff --git a/bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandler.java b/bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandler.java index 9fb8b60a9..a66224ec4 100644 --- a/bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandler.java +++ b/bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandler.java @@ -421,7 +421,7 @@ public class SensiboSkyHandler extends SensiboBaseThingHandler implements Channe case TARGET_TEMPERATURE_PROPERTY: Unit temperatureUnit = sensiboSky.getTemperatureUnit(); TemperatureDTO validTemperatures = currentModeCapabilities.temperatures - .get(temperatureUnit == SIUnits.CELSIUS ? "C" : "F"); + .get(SIUnits.CELSIUS.equals(temperatureUnit) ? "C" : "F"); DecimalType rawValue = (DecimalType) newPropertyValue; stateChange.updateValue(rawValue.intValue()); if (!validTemperatures.validValues.contains(rawValue.intValue())) { diff --git a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java index 822f09078..b04a8417f 100644 --- a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java +++ b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java @@ -2541,6 +2541,7 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici } } + @SuppressWarnings("PMD.CompareObjectsWithEquals") public boolean publicAddress(LineInType lineInType) { // check if sourcePlayer has a line-in connected if ((lineInType != LineInType.DIGITAL && isAnalogLineInConnected()) diff --git a/bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVHandler.java b/bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVHandler.java index aaa539dbc..1a86a1f77 100644 --- a/bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVHandler.java +++ b/bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVHandler.java @@ -124,7 +124,7 @@ public class ValloxMVHandler extends BaseThingHandler { // Not writable channel return; } - if (strUpdateValue != "") { + if (!strUpdateValue.isEmpty()) { if (readDataJob != null) { // Re-schedule readDataJob to read device values after data write // Avoid re-scheduling job several times in case of subsequent data writes diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/discovery/VeluxDiscoveryService.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/discovery/VeluxDiscoveryService.java index 53ec7faad..6c5c706b1 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/discovery/VeluxDiscoveryService.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/discovery/VeluxDiscoveryService.java @@ -68,6 +68,7 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService implements R // Private + @SuppressWarnings("PMD.CompareObjectsWithEquals") private void updateLocalization() { if (localization == Localization.UNKNOWN && localeProvider != null && i18nProvider != null) { logger.trace("updateLocalization(): creating Localization based on locale={},translation={}).", diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/factory/VeluxHandlerFactory.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/factory/VeluxHandlerFactory.java index 58025f8a7..3e210a179 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/factory/VeluxHandlerFactory.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/factory/VeluxHandlerFactory.java @@ -125,6 +125,7 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory { }); } + @SuppressWarnings("PMD.CompareObjectsWithEquals") private void updateLocalization() { if (localization == Localization.UNKNOWN && localeProvider != null && i18nProvider != null) { logger.trace("updateLocalization(): creating Localization based on locale={},translation={}).", diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelActuatorPosition.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelActuatorPosition.java index b636b6051..30f2bc9e2 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelActuatorPosition.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelActuatorPosition.java @@ -129,6 +129,7 @@ final class ChannelActuatorPosition extends ChannelHandlerTemplate { * information for this channel. * @return newValue ... */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") static @Nullable Command handleCommand(ChannelUID channelUID, String channelId, Command command, VeluxBridgeHandler thisBridgeHandler) { LOGGER.debug("handleCommand({},{},{},{}) called.", channelUID, channelId, command, thisBridgeHandler); diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelVShutterPosition.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelVShutterPosition.java index 59c8fc647..16272cb3e 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelVShutterPosition.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelVShutterPosition.java @@ -107,6 +107,7 @@ final class ChannelVShutterPosition extends ChannelHandlerTemplate { * information for this channel. * @return newValue ... */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") static @Nullable Command handleCommand(ChannelUID channelUID, String channelId, Command command, VeluxBridgeHandler thisBridgeHandler) { LOGGER.debug("handleCommand({},{},{},{}) called.", channelUID, channelId, command, thisBridgeHandler); diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/utils/Thing2VeluxActuator.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/utils/Thing2VeluxActuator.java index a225da45d..00964d968 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/utils/Thing2VeluxActuator.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/utils/Thing2VeluxActuator.java @@ -135,6 +135,7 @@ public class Thing2VeluxActuator { * * @return bridgeProductIndex for accessing the Velux device (or ProductBridgeIndex.UNKNOWN if not found). */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") public ProductBridgeIndex getProductBridgeIndex() { if (thisProduct == VeluxProduct.UNKNOWN) { mapThing2Velux(); @@ -151,6 +152,7 @@ public class Thing2VeluxActuator { * * @return isKnown as boolean. */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") public boolean isKnown() { return (!(this.getProductBridgeIndex() == ProductBridgeIndex.UNKNOWN)); } @@ -162,6 +164,7 @@ public class Thing2VeluxActuator { * * @return isInverted for handling of values of the Velux device (or false if not found).. */ + @SuppressWarnings("PMD.CompareObjectsWithEquals") public boolean isInverted() { if (thisProduct == VeluxProduct.UNKNOWN) { mapThing2Velux(); diff --git a/bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/VentaThingHandler.java b/bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/VentaThingHandler.java index ede6692f6..396c37c20 100644 --- a/bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/VentaThingHandler.java +++ b/bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/VentaThingHandler.java @@ -159,7 +159,7 @@ public class VentaThingHandler extends BaseThingHandler { if (config.macAddress.isEmpty()) { return "Mac Address not set, use discovery to find the correct one"; } - if (config.deviceType == BigDecimal.ZERO) { + if (BigDecimal.ZERO.equals(config.deviceType)) { return "Device Type not set, use discovery to find the correct one"; } if (config.pollingTime.compareTo(BigDecimal.ZERO) <= 0) { diff --git a/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedHandler.java b/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedHandler.java index 0f08a076c..d61d890f5 100644 --- a/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedHandler.java +++ b/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedHandler.java @@ -318,7 +318,7 @@ public class WLedHandler extends BaseThingHandler { } } } else if (command instanceof HSBType) { - if ((((HSBType) command).getBrightness()) == PercentType.ZERO) { + if (PercentType.ZERO.equals(((HSBType) command).getBrightness())) { sendGetRequest("/win&TT=500&T=0"); } primaryColor = (HSBType) command; diff --git a/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/HueEmulationService.java b/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/HueEmulationService.java index 1bc783b70..9ce8ac1be 100644 --- a/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/HueEmulationService.java +++ b/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/HueEmulationService.java @@ -87,7 +87,7 @@ public class HueEmulationService implements EventHandler { * Jetty returns 415 on any GET request if a client sends the Content-Type header. * This is a workaround - stripping it away in the preMatching stage. */ - if (requestContext.getMethod() == HttpMethod.GET + if (HttpMethod.GET.equals(requestContext.getMethod()) && requestContext.getHeaders().containsKey(HttpHeader.CONTENT_TYPE.asString())) { requestContext.getHeaders().remove(HttpHeader.CONTENT_TYPE.asString()); } diff --git a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/dto/ItemVO.java b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/dto/ItemVO.java index a7cec8960..8620ee58c 100644 --- a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/dto/ItemVO.java +++ b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/dto/ItemVO.java @@ -14,6 +14,7 @@ package org.openhab.persistence.jdbc.dto; import java.io.Serializable; import java.util.Date; +import java.util.Objects; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -140,7 +141,7 @@ public class ItemVO implements Serializable { } else if (!value.equals(other.value)) { return false; } - return time == other.time; + return Objects.equals(time, other.time); } @Override diff --git a/bundles/org.openhab.voice.mactts/src/test/java/org/openhab/voice/mactts/internal/MacTTSVoiceTest.java b/bundles/org.openhab.voice.mactts/src/test/java/org/openhab/voice/mactts/internal/MacTTSVoiceTest.java index 8816b9881..54927dd6f 100644 --- a/bundles/org.openhab.voice.mactts/src/test/java/org/openhab/voice/mactts/internal/MacTTSVoiceTest.java +++ b/bundles/org.openhab.voice.mactts/src/test/java/org/openhab/voice/mactts/internal/MacTTSVoiceTest.java @@ -82,7 +82,7 @@ public class MacTTSVoiceTest { */ @Test public void getLocaleTest() throws IOException { - assumeTrue("Mac OS X" == System.getProperty("os.name")); + assumeTrue("Mac OS X".equals(System.getProperty("os.name"))); Process process = Runtime.getRuntime().exec("say -v ?"); try (InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream()); BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { diff --git a/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/internal/wwn/dto/WWNDataUtil.java b/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/internal/wwn/dto/WWNDataUtil.java index b69895eba..53e5eb129 100644 --- a/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/internal/wwn/dto/WWNDataUtil.java +++ b/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/internal/wwn/dto/WWNDataUtil.java @@ -80,9 +80,9 @@ public final class WWNDataUtil { public static String fromFile(String fileName, Unit temperatureUnit) throws IOException { String json = fromFile(fileName); - if (temperatureUnit == SIUnits.CELSIUS) { + if (SIUnits.CELSIUS.equals(temperatureUnit)) { json = json.replace("\"temperature_scale\": \"F\"", "\"temperature_scale\": \"C\""); - } else if (temperatureUnit == ImperialUnits.FAHRENHEIT) { + } else if (ImperialUnits.FAHRENHEIT.equals(temperatureUnit)) { json = json.replace("\"temperature_scale\": \"C\"", "\"temperature_scale\": \"F\""); } return json;