Fix/suppress PMD CompareObjectsWithEquals findings (#11476)

Newer PMD versions discover more CompareObjectsWithEquals findings.

Related to https://github.com/openhab/static-code-analysis/pull/423

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2021-11-02 10:43:53 +01:00 committed by GitHub
parent b67b9fcb25
commit 589400e223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
82 changed files with 175 additions and 141 deletions

View File

@ -50,6 +50,7 @@ public abstract class State {
/** /**
* Sets a new state in the state machine. * Sets a new state in the state machine.
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public synchronized void nextState(Function<StateMachine, ? extends State> nextState) { public synchronized void nextState(Function<StateMachine, ? extends State> nextState) {
if (context.getState() != this) { // compare identity if (context.getState() != this) { // compare identity
return; return;

View File

@ -137,6 +137,7 @@ public class PacketCapturingService {
* @param packet The packet to be checked * @param packet The packet to be checked
* @return Returns true, if the packet should be captured, otherwise false * @return Returns true, if the packet should be captured, otherwise false
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private boolean shouldCapture(final Packet packet) { private boolean shouldCapture(final Packet packet) {
if (packet.contains(ArpPacket.class)) { if (packet.contains(ArpPacket.class)) {
ArpPacket arpPacket = packet.get(ArpPacket.class); ArpPacket arpPacket = packet.get(ArpPacket.class);

View File

@ -173,7 +173,7 @@ public class AccountServlet extends HttpServlet {
+ uri.substring(PROXY_URI_PART.length()); + uri.substring(PROXY_URI_PART.length());
String postData = null; String postData = null;
if (verb == "POST" || verb == "PUT") { if ("POST".equals(verb) || "PUT".equals(verb)) {
postData = req.getReader().lines().collect(Collectors.joining(System.lineSeparator())); postData = req.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
} }

View File

@ -157,6 +157,7 @@ public class FlashBriefingProfileHandler extends BaseThingHandler {
} }
} }
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public boolean initialize(AccountHandler handler, String currentConfigurationJson) { public boolean initialize(AccountHandler handler, String currentConfigurationJson) {
updateState(CHANNEL_SAVE, OnOffType.OFF); updateState(CHANNEL_SAVE, OnOffType.OFF);
if (updatePlayOnDevice) { if (updatePlayOnDevice) {

View File

@ -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 * Stops the reader. Will wait 5 seconds for the runnable to stop (should stop within 1 second based on the poll
* timeout below) * timeout below)
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void stopRunning() { public void stopRunning() {
if (isRunning.getAndSet(false)) { if (isRunning.getAndSet(false)) {
// only wait if stopRunning didn't get called as part of processing a message // only wait if stopRunning didn't get called as part of processing a message

View File

@ -1088,7 +1088,7 @@ class AtlonaPro3PortocolHandler {
@Override @Override
public void responseReceived(String response) { public void responseReceived(String response) {
if (response == null || response == "") { if (response == null || response.isEmpty()) {
return; return;
} }

View File

@ -554,6 +554,6 @@ public class AutelisHandler extends BaseThingHandler {
} }
private boolean isJandy() { private boolean isJandy() {
return getThing().getThingTypeUID() == AutelisBindingConstants.JANDY_THING_TYPE_UID; return AutelisBindingConstants.JANDY_THING_TYPE_UID.equals(getThing().getThingTypeUID());
} }
} }

View File

@ -83,6 +83,7 @@ public class BlueZBluetoothDevice extends BaseBluetoothDevice implements BlueZEv
logger.debug("Creating DBusBlueZ device with address '{}'", address); logger.debug("Creating DBusBlueZ device with address '{}'", address);
} }
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public synchronized void updateBlueZDevice(@Nullable BluetoothDevice blueZDevice) { public synchronized void updateBlueZDevice(@Nullable BluetoothDevice blueZDevice) {
if (this.device != null && this.device == blueZDevice) { if (this.device != null && this.device == blueZDevice) {
return; return;

View File

@ -104,6 +104,7 @@ public class RoamingBluetoothDevice extends DelegateBluetoothDevice {
return getAdapter(currentDelegateRef.get()); return getAdapter(currentDelegateRef.get());
} }
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private class Listener implements BluetoothDeviceListener { private class Listener implements BluetoothDeviceListener {
private BluetoothDevice device; private BluetoothDevice device;

View File

@ -143,6 +143,7 @@ public class RoamingBridgeHandler extends BaseBridgeHandler implements RoamingBl
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void addBluetoothAdapter(BluetoothAdapter adapter) { public void addBluetoothAdapter(BluetoothAdapter adapter) {
if (adapter == this) { if (adapter == this) {
return; return;
@ -164,6 +165,7 @@ public class RoamingBridgeHandler extends BaseBridgeHandler implements RoamingBl
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void removeBluetoothAdapter(BluetoothAdapter adapter) { public void removeBluetoothAdapter(BluetoothAdapter adapter) {
if (adapter == this) { if (adapter == this) {
return; return;

View File

@ -109,6 +109,7 @@ public class ConnectedBluetoothHandler extends BeaconBluetoothHandler {
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void dispose() { public void dispose() {
cancel(reconnectJob, true); cancel(reconnectJob, true);
reconnectJob = null; reconnectJob = null;
@ -181,6 +182,7 @@ public class ConnectedBluetoothHandler extends BeaconBluetoothHandler {
return characteristic; return characteristic;
} }
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private <T> CompletableFuture<T> executeWithConnection(UUID serviceUUID, UUID characteristicUUID, private <T> CompletableFuture<T> executeWithConnection(UUID serviceUUID, UUID characteristicUUID,
Function<BluetoothCharacteristic, CompletableFuture<T>> callable) { Function<BluetoothCharacteristic, CompletableFuture<T>> callable) {
if (connectionTaskExecutor == scheduler) { if (connectionTaskExecutor == scheduler) {

View File

@ -67,6 +67,7 @@ public class HeritableFuture<T> extends CompletableFuture<T> {
return new HeritableFuture<>(this); return new HeritableFuture<>(this);
} }
@SuppressWarnings("PMD.CompareObjectsWithEquals")
protected void setParentFuture(Supplier<@Nullable Future<?>> futureSupplier) { protected void setParentFuture(Supplier<@Nullable Future<?>> futureSupplier) {
synchronized (futureLock) { synchronized (futureLock) {
var future = futureSupplier.get(); var future = futureSupplier.get();

View File

@ -291,7 +291,7 @@ public class ConnectedDriveProxy {
ContentResponse authResponse = authRequest.timeout(HTTP_TIMEOUT_SEC, TimeUnit.SECONDS).send(); ContentResponse authResponse = authRequest.timeout(HTTP_TIMEOUT_SEC, TimeUnit.SECONDS).send();
String authResponseString = URLDecoder.decode(authResponse.getContentAsString(), Charset.defaultCharset()); String authResponseString = URLDecoder.decode(authResponse.getContentAsString(), Charset.defaultCharset());
String authCode = getAuthCode(authResponseString); String authCode = getAuthCode(authResponseString);
if (authCode != Constants.EMPTY) { if (!Constants.EMPTY.equals(authCode)) {
MultiMap<String> codeChallenge = getTokenBaseValues(); MultiMap<String> codeChallenge = getTokenBaseValues();
codeChallenge.put(AUTHORIZATION, authCode); codeChallenge.put(AUTHORIZATION, authCode);

View File

@ -171,11 +171,11 @@ public class Enums {
* @return the enum value representing the given measure unit * @return the enum value representing the given measure unit
*/ */
public static MeasureUnit fromUnit(Unit<?> unit) { public static MeasureUnit fromUnit(Unit<?> unit) {
if (unit == SIUnits.CELSIUS) { if (SIUnits.CELSIUS.equals(unit)) {
return CELSIUS; return CELSIUS;
} else if (unit == ImperialUnits.FAHRENHEIT) { } else if (ImperialUnits.FAHRENHEIT.equals(unit)) {
return FAHRENHEIT; return FAHRENHEIT;
} else if (unit == Units.PERCENT) { } else if (Units.PERCENT.equals(unit)) {
return PERCENTAGE; return PERCENTAGE;
} else { } else {
return DIMENSIONLESS; return DIMENSIONLESS;

View File

@ -235,7 +235,7 @@ public abstract class CaddxBaseThingHandler extends BaseThingHandler {
List<Channel> channels = getThing().getChannels(); List<Channel> channels = getThing().getChannels();
for (Channel ch : channels) { for (Channel ch : channels) {
if (channelUID == ch.getUID()) { if (channelUID.equals(ch.getUID())) {
channel = ch; channel = ch;
break; break;
} }

View File

@ -786,6 +786,7 @@ public enum ComfoAirCommandType {
* new state * new state
* @return initialized ComfoAirCommand * @return initialized ComfoAirCommand
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public static @Nullable ComfoAirCommand getChangeCommand(String key, Command command) { public static @Nullable ComfoAirCommand getChangeCommand(String key, Command command) {
ComfoAirCommandType commandType = getCommandTypeByKey(key); ComfoAirCommandType commandType = getCommandTypeByKey(key);
State value = UnDefType.NULL; State value = UnDefType.NULL;

View File

@ -19,6 +19,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
@ -463,8 +464,8 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager {
} }
sendComandsToDSS(device, intDeviceStateUpdate); sendComandsToDSS(device, intDeviceStateUpdate);
if (nextDeviceStateUpdate != null) { if (nextDeviceStateUpdate != null) {
if (intDeviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_CONFIG if (DeviceStateUpdate.UPDATE_SCENE_CONFIG.equals(intDeviceStateUpdate.getType())
|| intDeviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_OUTPUT) { || DeviceStateUpdate.UPDATE_SCENE_OUTPUT.equals(intDeviceStateUpdate.getType())) {
updateSceneData(device, intDeviceStateUpdate); updateSceneData(device, intDeviceStateUpdate);
} else { } else {
sendComandsToDSS(device, intDeviceStateUpdate); sendComandsToDSS(device, intDeviceStateUpdate);
@ -625,7 +626,7 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager {
// to // to
// OFFLINE. // OFFLINE.
// An alternate algorithm is responsible for deletion. // An alternate algorithm is responsible for deletion.
if (newDevice.isPresent() != internalDevice.isPresent()) { if (!Objects.equals(newDevice.isPresent(), internalDevice.isPresent())) {
internalDevice.setIsPresent(newDevice.isPresent()); internalDevice.setIsPresent(newDevice.isPresent());
} }
if (newDevice.getMeterDSID() != null && !newDevice.getMeterDSID().equals(internalDevice.getMeterDSID())) { if (newDevice.getMeterDSID() != null && !newDevice.getMeterDSID().equals(internalDevice.getMeterDSID())) {
@ -757,9 +758,9 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager {
while (!device.isDeviceUpToDate()) { while (!device.isDeviceUpToDate()) {
DeviceStateUpdate deviceStateUpdate = device.getNextDeviceUpdateState(); DeviceStateUpdate deviceStateUpdate = device.getNextDeviceUpdateState();
if (deviceStateUpdate != null) { if (deviceStateUpdate != null) {
if (deviceStateUpdate.getType() != DeviceStateUpdate.OUTPUT) { if (!DeviceStateUpdate.OUTPUT.equals(deviceStateUpdate.getType())) {
if (deviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_CONFIG if (DeviceStateUpdate.UPDATE_SCENE_CONFIG.equals(deviceStateUpdate.getType())
|| deviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_OUTPUT) { || DeviceStateUpdate.UPDATE_SCENE_OUTPUT.equals(deviceStateUpdate.getType())) {
updateSceneData(device, deviceStateUpdate); updateSceneData(device, deviceStateUpdate);
} else { } else {
sendComandsToDSS(device, deviceStateUpdate); sendComandsToDSS(device, deviceStateUpdate);
@ -767,14 +768,14 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager {
} else { } else {
DeviceStateUpdate nextDeviceStateUpdate = device.getNextDeviceUpdateState(); DeviceStateUpdate nextDeviceStateUpdate = device.getNextDeviceUpdateState();
while (nextDeviceStateUpdate != null while (nextDeviceStateUpdate != null
&& nextDeviceStateUpdate.getType() == DeviceStateUpdate.OUTPUT) { && DeviceStateUpdate.OUTPUT.equals(nextDeviceStateUpdate.getType())) {
deviceStateUpdate = nextDeviceStateUpdate; deviceStateUpdate = nextDeviceStateUpdate;
nextDeviceStateUpdate = device.getNextDeviceUpdateState(); nextDeviceStateUpdate = device.getNextDeviceUpdateState();
} }
sendComandsToDSS(device, deviceStateUpdate); sendComandsToDSS(device, deviceStateUpdate);
if (nextDeviceStateUpdate != null) { if (nextDeviceStateUpdate != null) {
if (deviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_CONFIG if (DeviceStateUpdate.UPDATE_SCENE_CONFIG.equals(deviceStateUpdate.getType())
|| deviceStateUpdate.getType() == DeviceStateUpdate.UPDATE_SCENE_OUTPUT) { || DeviceStateUpdate.UPDATE_SCENE_OUTPUT.equals(deviceStateUpdate.getType())) {
updateSceneData(device, deviceStateUpdate); updateSceneData(device, deviceStateUpdate);
} else { } else {
sendComandsToDSS(device, deviceStateUpdate); sendComandsToDSS(device, deviceStateUpdate);

View File

@ -314,7 +314,7 @@ public class TunableWhiteThingHandler extends DmxThingHandler {
private void updateCurrentBrightnessAndTemperature() { private void updateCurrentBrightnessAndTemperature() {
currentBrightness = Util.toPercentValue(Util.toDmxValue(currentValues.get(0) + currentValues.get(1))); currentBrightness = Util.toPercentValue(Util.toDmxValue(currentValues.get(0) + currentValues.get(1)));
if (currentBrightness != PercentType.ZERO) { if (!PercentType.ZERO.equals(currentBrightness)) {
currentColorTemperature = new PercentType( currentColorTemperature = new PercentType(
100 * currentValues.get(1) / (currentValues.get(0) + currentValues.get(1))); 100 * currentValues.get(1) / (currentValues.get(0) + currentValues.get(1)));
} }

View File

@ -322,7 +322,7 @@ public abstract class DSCAlarmBaseThingHandler extends BaseThingHandler {
List<Channel> channels = getThing().getChannels(); List<Channel> channels = getThing().getChannels();
for (Channel ch : channels) { for (Channel ch : channels) {
if (channelUID == ch.getUID()) { if (ch.getUID().equals(channelUID)) {
channel = ch; channel = ch;
break; break;
} }

View File

@ -100,40 +100,34 @@ public class KeypadThingHandler extends DSCAlarmBaseThingHandler {
String[] channelTypes = { KEYPAD_READY_LED, KEYPAD_ARMED_LED, KEYPAD_MEMORY_LED, KEYPAD_BYPASS_LED, 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 }; KEYPAD_TROUBLE_LED, KEYPAD_PROGRAM_LED, KEYPAD_FIRE_LED, KEYPAD_BACKLIGHT_LED };
String channel;
ChannelUID channelUID = null;
DSCAlarmCode dscAlarmCode = DSCAlarmCode DSCAlarmCode dscAlarmCode = DSCAlarmCode
.getDSCAlarmCodeValue(dscAlarmMessage.getMessageInfo(DSCAlarmMessageInfoType.CODE)); .getDSCAlarmCodeValue(dscAlarmMessage.getMessageInfo(DSCAlarmMessageInfoType.CODE));
int bitCount = 8;
int bitField = Integer.decode("0x" + dscAlarmMessage.getMessageInfo(DSCAlarmMessageInfoType.DATA)); int bitField = Integer.decode("0x" + dscAlarmMessage.getMessageInfo(DSCAlarmMessageInfoType.DATA));
int[] masks = { 1, 2, 4, 8, 16, 32, 64, 128 }; 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]; bits[i] = bitField & masks[i];
ChannelUID channelUID = new ChannelUID(getThing().getUID(), channelTypes[i]);
channel = channelTypes[i]; switch (dscAlarmCode) {
case KeypadLEDState: /* 510 */
if (channel != "") { updateChannel(channelUID, bits[i] != 0 ? 1 : 0, "");
channelUID = new ChannelUID(getThing().getUID(), channel); break;
case KeypadLEDFlashState: /* 511 */
switch (dscAlarmCode) { if (bits[i] != 0) {
case KeypadLEDState: /* 510 */ updateChannel(channelUID, 2, "");
updateChannel(channelUID, bits[i] != 0 ? 1 : 0, ""); }
break; break;
case KeypadLEDFlashState: /* 511 */ default:
if (bits[i] != 0) { break;
updateChannel(channelUID, 2, "");
}
break;
default:
break;
}
} }
} }
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void dscAlarmEventReceived(EventObject event, Thing thing) { public void dscAlarmEventReceived(EventObject event, Thing thing) {
if (thing != null) { if (thing != null) {
if (getThing() == thing) { if (getThing() == thing) {

View File

@ -257,19 +257,11 @@ public class PanelThingHandler extends DSCAlarmBaseThingHandler {
* @param timeStamp * @param timeStamp
*/ */
private void setTimeStampState(String timeStamp) { private void setTimeStampState(String timeStamp) {
int state = 0; if (timeStamp != null) {
ChannelUID channelUID = new ChannelUID(getThing().getUID(), PANEL_TIME_STAMP); ChannelUID channelUID = new ChannelUID(getThing().getUID(), PANEL_TIME_STAMP);
int state = timeStamp.isEmpty() ? 0 : 1;
boolean isTimeStamp = timeStamp != ""; updateChannel(channelUID, state, "");
if ((timeStamp == "" && !isTimeStamp) || (timeStamp != "" && isTimeStamp)) {
logger.debug("setTimeStampState(): Already Set: {}", timeStamp);
return;
} else if (timeStamp != "") {
state = 1;
} }
updateChannel(channelUID, state, "");
} }
/** /**
@ -391,19 +383,15 @@ public class PanelThingHandler extends DSCAlarmBaseThingHandler {
String channel; String channel;
ChannelUID channelUID = null; ChannelUID channelUID = null;
int bitCount = 8;
int bitField = Integer.decode("0x" + dscAlarmMessage.getMessageInfo(DSCAlarmMessageInfoType.DATA)); int bitField = Integer.decode("0x" + dscAlarmMessage.getMessageInfo(DSCAlarmMessageInfoType.DATA));
int[] masks = { 1, 2, 4, 8, 16, 32, 64, 128 }; 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]; bits[i] = bitField & masks[i];
updateChannel(channelUID, bits[i] != 0 ? 1 : 0, "");
channel = channelTypes[i];
if (channel != "") {
channelUID = new ChannelUID(getThing().getUID(), channel);
updateChannel(channelUID, bits[i] != 0 ? 1 : 0, "");
}
} }
} }
@ -436,6 +424,7 @@ public class PanelThingHandler extends DSCAlarmBaseThingHandler {
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void dscAlarmEventReceived(EventObject event, Thing thing) { public void dscAlarmEventReceived(EventObject event, Thing thing) {
if (thing != null) { if (thing != null) {
DSCAlarmEvent dscAlarmEvent = (DSCAlarmEvent) event; DSCAlarmEvent dscAlarmEvent = (DSCAlarmEvent) event;

View File

@ -184,6 +184,7 @@ public class PartitionThingHandler extends DSCAlarmBaseThingHandler {
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void dscAlarmEventReceived(EventObject event, Thing thing) { public void dscAlarmEventReceived(EventObject event, Thing thing) {
if (thing != null) { if (thing != null) {
if (getThing() == thing) { if (getThing() == thing) {

View File

@ -223,6 +223,7 @@ public class DSMRSerialAutoDevice implements DSMRDevice, DSMREventListener {
/** /**
* Switches the baudrate on the serial port. * Switches the baudrate on the serial port.
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private void switchBaudrate() { private void switchBaudrate() {
if (lastSwitchedBaudrateNanos + SWITCHING_BAUDRATE_TIMEOUT_NANOS > System.nanoTime()) { if (lastSwitchedBaudrateNanos + SWITCHING_BAUDRATE_TIMEOUT_NANOS > System.nanoTime()) {
// Ignore switching baudrate if this is called within the timeout after a previous switch. // Ignore switching baudrate if this is called within the timeout after a previous switch.

View File

@ -13,6 +13,7 @@
package org.openhab.binding.dwdunwetter.internal.dto; package org.openhab.binding.dwdunwetter.internal.dto;
import java.util.Comparator; import java.util.Comparator;
import java.util.Objects;
/** /**
* Comperator to sort a Warning first by Severity, second by the onSet date. * Comperator to sort a Warning first by Severity, second by the onSet date.
@ -28,7 +29,7 @@ public class SeverityComparator implements Comparator<DwdWarningData> {
int result = Integer.compare(o1.getSeverity().getOrder(), o2.getSeverity().getOrder()); int result = Integer.compare(o1.getSeverity().getOrder(), o2.getSeverity().getOrder());
if (result == 0) { if (result == 0) {
if (o1.getOnset() == o2.getOnset()) { if (Objects.equals(o1.getOnset(), o2.getOnset())) {
return 0; return 0;
} else if (o1.getOnset() == null) { } else if (o1.getOnset() == null) {
return -1; return -1;

View File

@ -193,27 +193,28 @@ public class SelectionDTO {
this.includeRuntime = Boolean.TRUE; this.includeRuntime = Boolean.TRUE;
this.includeSensors = Boolean.TRUE; this.includeSensors = Boolean.TRUE;
this.includeAudio = selection.includeAudio == Boolean.TRUE ? Boolean.TRUE : includeAudio; this.includeAudio = Boolean.TRUE.equals(selection.includeAudio) ? Boolean.TRUE : includeAudio;
this.includeDevice = selection.includeDevice == Boolean.TRUE ? Boolean.TRUE : includeDevice; this.includeDevice = Boolean.TRUE.equals(selection.includeDevice) ? Boolean.TRUE : includeDevice;
this.includeElectricity = selection.includeElectricity == Boolean.TRUE ? Boolean.TRUE : includeElectricity; this.includeElectricity = Boolean.TRUE.equals(selection.includeElectricity) ? Boolean.TRUE : includeElectricity;
this.includeEnergy = selection.includeEnergy == Boolean.TRUE ? Boolean.TRUE : includeEnergy; this.includeEnergy = Boolean.TRUE.equals(selection.includeEnergy) ? Boolean.TRUE : includeEnergy;
this.includeExtendedRuntime = selection.includeExtendedRuntime == Boolean.TRUE ? Boolean.TRUE this.includeExtendedRuntime = Boolean.TRUE.equals(selection.includeExtendedRuntime) ? Boolean.TRUE
: includeExtendedRuntime; : includeExtendedRuntime;
this.includeHouseDetails = selection.includeHouseDetails == Boolean.TRUE ? Boolean.TRUE : includeHouseDetails; this.includeHouseDetails = Boolean.TRUE.equals(selection.includeHouseDetails) ? Boolean.TRUE
this.includeLocation = selection.includeLocation == Boolean.TRUE ? Boolean.TRUE : includeLocation; : includeHouseDetails;
this.includeManagement = selection.includeManagement == Boolean.TRUE ? Boolean.TRUE : includeManagement; this.includeLocation = Boolean.TRUE.equals(selection.includeLocation) ? Boolean.TRUE : includeLocation;
this.includeNotificationSettings = selection.includeNotificationSettings == Boolean.TRUE ? Boolean.TRUE this.includeManagement = Boolean.TRUE.equals(selection.includeManagement) ? Boolean.TRUE : includeManagement;
this.includeNotificationSettings = Boolean.TRUE.equals(selection.includeNotificationSettings) ? Boolean.TRUE
: includeNotificationSettings; : includeNotificationSettings;
this.includeOemCfg = selection.includeOemCfg == Boolean.TRUE ? Boolean.TRUE : includeOemCfg; this.includeOemCfg = Boolean.TRUE.equals(selection.includeOemCfg) ? Boolean.TRUE : includeOemCfg;
this.includePrivacy = selection.includePrivacy == Boolean.TRUE ? Boolean.TRUE : includePrivacy; this.includePrivacy = Boolean.TRUE.equals(selection.includePrivacy) ? Boolean.TRUE : includePrivacy;
this.includeReminders = selection.includeReminders == Boolean.TRUE ? Boolean.TRUE : includeReminders; this.includeReminders = Boolean.TRUE.equals(selection.includeReminders) ? Boolean.TRUE : includeReminders;
this.includeSecuritySettings = selection.includeSecuritySettings == Boolean.TRUE ? Boolean.TRUE this.includeSecuritySettings = Boolean.TRUE.equals(selection.includeSecuritySettings) ? Boolean.TRUE
: includeSecuritySettings; : includeSecuritySettings;
this.includeSettings = selection.includeSettings == Boolean.TRUE ? Boolean.TRUE : includeSettings; this.includeSettings = Boolean.TRUE.equals(selection.includeSettings) ? Boolean.TRUE : includeSettings;
this.includeTechnician = selection.includeTechnician == Boolean.TRUE ? Boolean.TRUE : includeTechnician; this.includeTechnician = Boolean.TRUE.equals(selection.includeTechnician) ? Boolean.TRUE : includeTechnician;
this.includeUtility = selection.includeUtility == Boolean.TRUE ? Boolean.TRUE : includeUtility; this.includeUtility = Boolean.TRUE.equals(selection.includeUtility) ? Boolean.TRUE : includeUtility;
this.includeVersion = selection.includeVersion == Boolean.TRUE ? Boolean.TRUE : includeVersion; this.includeVersion = Boolean.TRUE.equals(selection.includeVersion) ? Boolean.TRUE : includeVersion;
this.includeWeather = selection.includeWeather == Boolean.TRUE ? Boolean.TRUE : includeWeather; this.includeWeather = Boolean.TRUE.equals(selection.includeWeather) ? Boolean.TRUE : includeWeather;
return this; return this;
} }

View File

@ -47,6 +47,7 @@ public class Command implements Delayed {
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public int compareTo(Delayed delayed) { public int compareTo(Delayed delayed) {
if (delayed == this) { if (delayed == this) {
return 0; return 0;

View File

@ -30,6 +30,7 @@ public class DelayedCommand extends Command {
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public int compareTo(Delayed delayed) { public int compareTo(Delayed delayed) {
if (delayed == this) { if (delayed == this) {
return 0; return 0;

View File

@ -49,7 +49,7 @@ public class A5_3F_7F_Universal extends _4BSMessage {
String c = Transformation.transform(transformationInfo.transformationType, String c = Transformation.transform(transformationInfo.transformationType,
transformationInfo.transformationFunction, command.toString()); transformationInfo.transformationFunction, command.toString());
if (c != null && c != command.toString()) { if (c != null && !c.equals(command.toString())) {
setData(HexUtils.hexToBytes(c)); setData(HexUtils.hexToBytes(c));
} }

View File

@ -97,6 +97,7 @@ public class Ipx800v3Handler extends BaseThingHandler implements Ipx800EventList
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void run() { public void run() {
PortData currentData = portDatas.get(port); PortData currentData = portDatas.get(port);
if (currentData != null && currentData.getValue() == 1 && currentData.getTimestamp() == referenceTime) { if (currentData != null && currentData.getValue() == 1 && currentData.getTimestamp() == referenceTime) {

View File

@ -103,7 +103,7 @@ public class LocationMessage {
* @return Conversion result * @return Conversion result
*/ */
public State getTrackerLocation() { 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 new PointType(new DecimalType(latitude), new DecimalType(longitude));
} }
return UnDefType.UNDEF; return UnDefType.UNDEF;

View File

@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import org.eclipse.jdt.annotation.NonNullByDefault; 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 // 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 // temperature to use as celsius alone is ambigious
double newVal = temp.doubleValue(); double newVal = temp.doubleValue();
int CorF = temp.getUnit() == SIUnits.CELSIUS ? TEMP_UNIT_CELSIUS : TEMP_UNIT_FAHRENHEIT; // 0=Celsius, int CorF = SIUnits.CELSIUS.equals(temp.getUnit()) ? TEMP_UNIT_CELSIUS : TEMP_UNIT_FAHRENHEIT; // 0=Celsius,
// 1=Fahrenheit // 1=Fahrenheit
if (((CorF == TEMP_UNIT_CELSIUS) && (newVal < TEMP_MIN_C || newVal > TEMP_MAX_C)) 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))) { || ((CorF == TEMP_UNIT_FAHRENHEIT) && (newVal < TEMP_MIN_F || newVal > TEMP_MAX_F))) {
throw new IllegalArgumentException("Temp Value out of Range"); throw new IllegalArgumentException("Temp Value out of Range");
@ -404,7 +405,7 @@ public class GreeAirDevice {
} }
// Finally Compare the values // 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<String, Integer> parameters) throws GreeException { protected void executeCommand(DatagramSocket clientSocket, Map<String, Integer> parameters) throws GreeException {

View File

@ -170,7 +170,7 @@ public class HaywardDiscoveryService extends AbstractDiscoveryService implements
List<String> names; List<String> names;
// Set Virtual Heater Name // Set Virtual Heater Name
if (thingType == HaywardBindingConstants.THING_TYPE_VIRTUALHEATER) { if (HaywardBindingConstants.THING_TYPE_VIRTUALHEATER.equals(thingType)) {
names = new ArrayList<>(systemIDs); names = new ArrayList<>(systemIDs);
Collections.fill(names, "Heater"); Collections.fill(names, "Heater");
} else { } else {

View File

@ -309,6 +309,7 @@ public class HeliosVentilationDataPoint {
* *
* @param next is the sister datapoint * @param next is the sister datapoint
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void append(HeliosVentilationDataPoint next) { public void append(HeliosVentilationDataPoint next) {
HeliosVentilationDataPoint existing = this.next; HeliosVentilationDataPoint existing = this.next;
if (this == next) { if (this == next) {

View File

@ -42,7 +42,7 @@ public class OnOffTypeConverter extends AbstractTypeConverter<OnOffType> {
@Override @Override
protected OnOffType fromBinding(HmDatapoint dp) throws ConverterException { 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;
} }
/** /**

View File

@ -42,8 +42,7 @@ public class OpenClosedTypeConverter extends AbstractTypeConverter<OpenClosedTyp
@Override @Override
protected OpenClosedType fromBinding(HmDatapoint dp) throws ConverterException { protected OpenClosedType fromBinding(HmDatapoint dp) throws ConverterException {
return (((Boolean) dp.getValue()) == Boolean.FALSE) != isInvert(dp) ? OpenClosedType.CLOSED return Boolean.FALSE.equals(dp.getValue()) != isInvert(dp) ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
: OpenClosedType.OPEN;
} }
/** /**

View File

@ -71,9 +71,9 @@ public class PercentTypeConverter extends AbstractTypeConverter<PercentType> {
Double number = (type.doubleValue() / 100) * maxValue; Double number = (type.doubleValue() / 100) * maxValue;
if (MetadataUtils.isRollerShutter(dp)) { if (MetadataUtils.isRollerShutter(dp)) {
if (type == PercentType.HUNDRED) { // means DOWN if (PercentType.HUNDRED.equals(type)) { // means DOWN
return dp.getMinValue().doubleValue(); return dp.getMinValue().doubleValue();
} else if (type == PercentType.ZERO) { // means UP } else if (PercentType.ZERO.equals(type)) { // means UP
return maxValue; return maxValue;
} }
return maxValue - number; return maxValue - number;

View File

@ -41,14 +41,14 @@ public class MiscUtils {
* Returns true, if the value is not null and true. * Returns true, if the value is not null and true.
*/ */
public static boolean isTrueValue(Object value) { 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. * Returns true, if the value is not null and false.
*/ */
public static boolean isFalseValue(Object value) { public static boolean isFalseValue(Object value) {
return value != null && value == Boolean.FALSE; return Boolean.FALSE.equals(value);
} }
/** /**

View File

@ -175,7 +175,7 @@ public class MetadataUtils {
if ("%%".equals(unit)) { if ("%%".equals(unit)) {
return "%d %%"; return "%d %%";
} }
if (unit != null && unit != "") { if (unit != null && !unit.isEmpty()) {
String pattern = getPattern(dp); String pattern = getPattern(dp);
if (pattern != null) { if (pattern != null) {
return String.format("%s %s", pattern, "%unit%"); return String.format("%s %s", pattern, "%unit%");

View File

@ -206,7 +206,9 @@ public class IAqualinkHandler extends BaseThingHandler {
Optional<Auxiliary> optional = Arrays.stream(auxs).filter(o -> o.getName().equals(channelName)) Optional<Auxiliary> optional = Arrays.stream(auxs).filter(o -> o.getName().equals(channelName))
.findFirst(); .findFirst();
if (optional.isPresent()) { 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); client.auxSetCommand(serialNumber, sessionId, channelName);
} }
} }
@ -225,20 +227,23 @@ public class IAqualinkHandler extends BaseThingHandler {
} }
} }
} else if (command instanceof OnOffType) { } else if (command instanceof OnOffType) {
OnOffType onOffCommand = (OnOffType) command;
// these are toggle commands and require we have the current state to turn on/off // these are toggle commands and require we have the current state to turn on/off
if (channelName.startsWith("onetouch_")) { if (channelName.startsWith("onetouch_")) {
OneTouch[] ota = client.getOneTouch(serialNumber, sessionId); OneTouch[] ota = client.getOneTouch(serialNumber, sessionId);
Optional<OneTouch> optional = Arrays.stream(ota).filter(o -> o.getName().equals(channelName)) Optional<OneTouch> optional = Arrays.stream(ota).filter(o -> o.getName().equals(channelName))
.findFirst(); .findFirst();
if (optional.isPresent()) { 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); logger.debug("Sending command {} to {}", command, channelName);
client.oneTouchSetCommand(serialNumber, sessionId, channelName); client.oneTouchSetCommand(serialNumber, sessionId, channelName);
} }
} }
} else if (channelName.endsWith("heater") || channelName.endsWith("pump")) { } else if (channelName.endsWith("heater") || channelName.endsWith("pump")) {
String value = client.getHome(serialNumber, sessionId).getSerializedMap().get(channelName); 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); logger.debug("Sending command {} to {}", command, channelName);
client.homeScreenSetCommand(serialNumber, sessionId, channelName); client.homeScreenSetCommand(serialNumber, sessionId, channelName);
} }

View File

@ -190,7 +190,7 @@ public class Device {
* @return * @return
*/ */
public boolean hasSerialNumber() { public boolean hasSerialNumber() {
return (serialnumber != null && serialnumber != ""); return serialnumber != null && !serialnumber.isEmpty();
} }
/** /**

View File

@ -731,7 +731,7 @@ public abstract class CommandHandler {
int ilevel = dc * intFactor; int ilevel = dc * intFactor;
byte level = (byte) (ilevel > 255 ? 0xFF : ((ilevel < 0) ? 0 : ilevel)); byte level = (byte) (ilevel > 255 ? 0xFF : ((ilevel < 0) ? 0 : ilevel));
String vfield = getStringParameter("value", ""); String vfield = getStringParameter("value", "");
if (vfield == "") { if (vfield == null || vfield.isEmpty()) {
logger.warn("{} has no value field specified", nm()); logger.warn("{} has no value field specified", nm());
} }
// //

View File

@ -107,6 +107,7 @@ public abstract class MessageDispatcher {
* @param msg * @param msg
* @return true; * @return true;
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
boolean isMyDirectAck(Msg msg) { boolean isMyDirectAck(Msg msg) {
return msg.isAckOfDirect() && (feature.getQueryStatus() == DeviceFeature.QueryStatus.QUERY_PENDING) return msg.isAckOfDirect() && (feature.getQueryStatus() == DeviceFeature.QueryStatus.QUERY_PENDING)
&& feature.getDevice().getFeatureQueried() == feature; && feature.getDevice().getFeatureQueried() == feature;

View File

@ -359,6 +359,7 @@ public class IpCameraHandler extends BaseThingHandler {
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void userEventTriggered(@Nullable ChannelHandlerContext ctx, @Nullable Object evt) throws Exception { public void userEventTriggered(@Nullable ChannelHandlerContext ctx, @Nullable Object evt) throws Exception {
if (ctx == null) { if (ctx == null) {
return; 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 * open large amounts of channels. This may help to keep it under control and WARN the user every 8 seconds this is
* still occurring. * still occurring.
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private void cleanChannels() { private void cleanChannels() {
for (Channel channel : openChannels) { for (Channel channel : openChannels) {
boolean oldChannel = true; boolean oldChannel = true;

View File

@ -170,7 +170,7 @@ public class JeeLinkHandler extends BaseBridgeHandler implements BridgeHandler,
// this is the first handler for this reading class => also setup converter // this is the first handler for this reading class => also setup converter
readingClassHandlerMap.put(h.getReadingClass(), handlers); readingClassHandlerMap.put(h.getReadingClass(), handlers);
if (SensorDefinition.ALL_TYPE == h.getSensorType()) { if (SensorDefinition.ALL_TYPE.equals(h.getSensorType())) {
converters.addAll(SensorDefinition.getDiscoveryConverters()); converters.addAll(SensorDefinition.getDiscoveryConverters());
} else { } else {
JeeLinkReadingConverter<?> c = SensorDefinition.getConverter(h.getSensorType()); 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 // this was the last handler for this reading class => also remove converter
readingClassHandlerMap.remove(h.getReadingClass()); readingClassHandlerMap.remove(h.getReadingClass());
if (SensorDefinition.ALL_TYPE == h.getSensorType()) { if (SensorDefinition.ALL_TYPE.equals(h.getSensorType())) {
converters.removeAll(SensorDefinition.getDiscoveryConverters()); converters.removeAll(SensorDefinition.getDiscoveryConverters());
} else { } else {
JeeLinkReadingConverter<?> c = SensorDefinition.getConverter(h.getSensorType()); JeeLinkReadingConverter<?> c = SensorDefinition.getConverter(h.getSensorType());

View File

@ -135,7 +135,7 @@ public class SecondGenerationConfigurationHandler {
if (size > 0) { if (size > 0) {
extractSessionId = extractJsonArraySessionId.get(size - 1).getAsJsonObject().get("sessionId").getAsString(); 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: {}", sessionIdLogger.debug(" Login Post Json Reponse not OK! , inverter answered with sessionId like: {}",
extractSessionId); extractSessionId);
} }
@ -152,7 +152,7 @@ public class SecondGenerationConfigurationHandler {
if (size > 0) { if (size > 0) {
extractCode = extractJsonArrayCode.get(size - 1).getAsJsonObject().get("code").getAsString(); 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: {}", codeLogger.debug(" Login Post Json Reponse not OK! , inverter answered with status code like: {}",
extractCode); extractCode);
} }

View File

@ -99,6 +99,7 @@ public class LcnModuleDiscoveryService extends AbstractDiscoveryService
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
protected void startScan() { protected void startScan() {
synchronized (this) { synchronized (this) {
PckGatewayHandler localBridgeHandler = bridgeHandler; PckGatewayHandler localBridgeHandler = bridgeHandler;

View File

@ -54,6 +54,7 @@ public class LcnModuleRvarSetpointSubHandler extends AbstractLcnModuleVariableSu
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void handleStatusMessage(Matcher matcher) throws LcnException { public void handleStatusMessage(Matcher matcher) throws LcnException {
Variable variable; Variable variable;
if (matcher.pattern() == PATTERN) { if (matcher.pattern() == PATTERN) {

View File

@ -66,6 +66,7 @@ public class LcnModuleVariableSubHandler extends AbstractLcnModuleVariableSubHan
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void handleStatusMessage(Matcher matcher) throws LcnException { public void handleStatusMessage(Matcher matcher) throws LcnException {
Variable variable; Variable variable;
if (matcher.pattern() == PATTERN) { if (matcher.pattern() == PATTERN) {

View File

@ -12,6 +12,8 @@
*/ */
package org.openhab.binding.lifx.internal.dto; package org.openhab.binding.lifx.internal.dto;
import java.util.Arrays;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.lifx.internal.LifxBindingConstants; import org.openhab.binding.lifx.internal.LifxBindingConstants;
@ -153,7 +155,7 @@ public class Effect {
} }
Effect n = (Effect) o; Effect n = (Effect) o;
return n.getType().equals(this.getType()) && n.duration.equals(this.duration) && n.speed.equals(this.speed) 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 @Override

View File

@ -134,14 +134,14 @@ public class ChannelUpdaterJob implements SchedulerRunnable, Runnable {
if (unit == null) { if (unit == null) {
return new DecimalType(rawValue); return new DecimalType(rawValue);
} }
if (unit == SIUnits.CELSIUS || unit == Units.KELVIN || unit == Units.KILOWATT_HOUR || unit == Units.PERCENT if (SIUnits.CELSIUS.equals(unit) || Units.KELVIN.equals(unit) || Units.KILOWATT_HOUR.equals(unit)
|| unit == Units.HOUR) { || Units.PERCENT.equals(unit) || Units.HOUR.equals(unit)) {
return new QuantityType<>((double) rawValue / 10, 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); 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); 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); 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), var longState = String.format("%s - %s %s - %s", state, getStateTranslation("menuStateLine2", row2),
formatHours(time), getStateTranslation("menuStateLine3", row3)); 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) { private void updateProperties(Integer[] heatpumpValues) {

View File

@ -854,8 +854,8 @@ public class HeliosEasyControlsHandler extends BaseThingHandler {
} }
switch (itemType) { switch (itemType) {
case "Number": case "Number":
if (((variableType.equals(HeliosVariable.TYPE_INTEGER)) if (((HeliosVariable.TYPE_INTEGER.equals(variableType))
|| (variableType == HeliosVariable.TYPE_FLOAT)) && (!value.equals("-"))) { || (HeliosVariable.TYPE_FLOAT.equals(variableType))) && (!value.equals("-"))) {
State state = null; State state = null;
if (v.getUnit() == null) { if (v.getUnit() == null) {
state = DecimalType.valueOf(value); state = DecimalType.valueOf(value);

View File

@ -177,7 +177,7 @@ public class Property implements AttributeChanged {
Value value; Value value;
Boolean isDecimal = null; Boolean isDecimal = null;
if (attributes.name == "") { if (attributes.name.isEmpty()) {
attributes.name = propertyID; attributes.name = propertyID;
} }

View File

@ -93,6 +93,7 @@ public class SystemBrokerHandler extends AbstractBrokerHandler implements MqttSe
* is no connection established yet. * is no connection established yet.
*/ */
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void brokerAdded(String connectionName, MqttBrokerConnection addedConnection) { public void brokerAdded(String connectionName, MqttBrokerConnection addedConnection) {
if (!connectionName.equals(brokerID) || connection == addedConnection) { if (!connectionName.equals(brokerID) || connection == addedConnection) {
return; return;

View File

@ -128,7 +128,7 @@ public class NATherm1Handler extends NetatmoModuleHandler<NAThermostat> {
String currentPlanning = "-"; String currentPlanning = "-";
if (thermostat.isPresent()) { if (thermostat.isPresent()) {
for (NAThermProgram program : nonNullList(thermostat.get().getThermProgramList())) { for (NAThermProgram program : nonNullList(thermostat.get().getThermProgramList())) {
if (program.isSelected() == Boolean.TRUE) { if (Boolean.TRUE.equals(program.isSelected())) {
currentPlanning = program.getProgramId(); currentPlanning = program.getProgramId();
} }
} }

View File

@ -69,7 +69,7 @@ public abstract class OceanicThingHandler extends BaseThingHandler {
if (aChannel.getUID().equals(theChannelUID) if (aChannel.getUID().equals(theChannelUID)
&& selector.getTypeValue() == OceanicChannelSelector.ValueSelectorType.GET) { && selector.getTypeValue() == OceanicChannelSelector.ValueSelectorType.GET) {
String response = requestResponse(selector.name()); String response = requestResponse(selector.name());
if (response != null && response != "") { if (response != null && !response.isEmpty()) {
if (selector.isProperty()) { if (selector.isProperty()) {
logger.debug("Updating the property '{}' with value '{}'", selector.toString(), logger.debug("Updating the property '{}' with value '{}'", selector.toString(),
selector.convertValue(response)); selector.convertValue(response));

View File

@ -111,14 +111,14 @@ public class OpenThermGatewayHandler extends BaseThingHandler implements OpenThe
if (conn != null && conn.isConnected()) { if (conn != null && conn.isConnected()) {
conn.sendCommand(gatewayCommand); conn.sendCommand(gatewayCommand);
if (code == GatewayCommandCode.ControlSetpoint) { if (GatewayCommandCode.ControlSetpoint.equals(code)) {
if (gatewayCommand.getMessage().equals("0.0")) { if (gatewayCommand.getMessage().equals("0.0")) {
updateState(OpenThermGatewayBindingConstants.CHANNEL_OVERRIDE_CENTRAL_HEATING_WATER_SETPOINT, updateState(OpenThermGatewayBindingConstants.CHANNEL_OVERRIDE_CENTRAL_HEATING_WATER_SETPOINT,
UnDefType.UNDEF); UnDefType.UNDEF);
} }
updateState(OpenThermGatewayBindingConstants.CHANNEL_OVERRIDE_CENTRAL_HEATING_ENABLED, updateState(OpenThermGatewayBindingConstants.CHANNEL_OVERRIDE_CENTRAL_HEATING_ENABLED,
OnOffType.from(!gatewayCommand.getMessage().equals("0.0"))); OnOffType.from(!gatewayCommand.getMessage().equals("0.0")));
} else if (code == GatewayCommandCode.ControlSetpoint2) { } else if (GatewayCommandCode.ControlSetpoint2.equals(code)) {
if (gatewayCommand.getMessage().equals("0.0")) { if (gatewayCommand.getMessage().equals("0.0")) {
updateState(OpenThermGatewayBindingConstants.CHANNEL_OVERRIDE_CENTRAL_HEATING2_WATER_SETPOINT, updateState(OpenThermGatewayBindingConstants.CHANNEL_OVERRIDE_CENTRAL_HEATING2_WATER_SETPOINT,
UnDefType.UNDEF); UnDefType.UNDEF);

View File

@ -181,7 +181,7 @@ public class OpenUVReportHandler extends BaseThingHandler {
}); });
} else if (ELEVATION.equals(channelUID.getId()) && command instanceof QuantityType) { } else if (ELEVATION.equals(channelUID.getId()) && command instanceof QuantityType) {
QuantityType<?> qtty = (QuantityType<?>) command; QuantityType<?> qtty = (QuantityType<?>) command;
if (qtty.getUnit() == Units.DEGREE_ANGLE) { if (Units.DEGREE_ANGLE.equals(qtty.getUnit())) {
suspendUpdates = qtty.doubleValue() < 0; suspendUpdates = qtty.doubleValue() < 0;
} else { } else {
logger.info("The OpenUV Report handles Sun Elevation of Number:Angle type, {} does not fit.", command); logger.info("The OpenUV Report handles Sun Elevation of Number:Angle type, {} does not fit.", command);

View File

@ -176,7 +176,7 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService
} }
String ownId = bridgeHandler.ownIdFromWhoWhere(deviceWho, where); 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) { if (bridgeHandler.getRegisteredDevice(ownId) != null) {
logger.debug("dimmer/switch with WHERE={} already registered, skipping this discovery result", where); logger.debug("dimmer/switch with WHERE={} already registered, skipping this discovery result", where);
return; return;
@ -204,7 +204,7 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService
Map<String, Object> properties = new HashMap<>(2); Map<String, Object> properties = new HashMap<>(2);
properties.put(OpenWebNetBindingConstants.CONFIG_PROPERTY_WHERE, whereConfig); properties.put(OpenWebNetBindingConstants.CONFIG_PROPERTY_WHERE, whereConfig);
properties.put(OpenWebNetBindingConstants.PROPERTY_OWNID, ownId); 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 + ")"; thingLabel = thingLabel + " (WHO=" + deviceWho + ", WHERE=" + whereConfig + ")";
} else { } else {
thingLabel = thingLabel + " (WHERE=" + whereConfig + ")"; thingLabel = thingLabel + " (WHERE=" + whereConfig + ")";

View File

@ -17,6 +17,7 @@ import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
@ -458,13 +459,13 @@ public class OpenWebNetBridgeHandler extends ConfigStatusBridgeHandler implement
logger.info("---- CONNECTED to BUS gateway bridge '{}' ({}:{})", thing.getUID(), logger.info("---- CONNECTED to BUS gateway bridge '{}' ({}:{})", thing.getUID(),
((BUSGateway) gw).getHost(), ((BUSGateway) gw).getPort()); ((BUSGateway) gw).getHost(), ((BUSGateway) gw).getPort());
// update serial number property (with MAC address) // 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()); properties.put(PROPERTY_SERIAL_NO, gw.getMACAddr().toUpperCase());
propertiesChanged = true; propertiesChanged = true;
logger.debug("updated property gw serialNumber: {}", properties.get(PROPERTY_SERIAL_NO)); 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()); properties.put(PROPERTY_FIRMWARE_VERSION, gw.getFirmwareVersion());
propertiesChanged = true; propertiesChanged = true;
logger.debug("updated property gw firmware version: {}", properties.get(PROPERTY_FIRMWARE_VERSION)); logger.debug("updated property gw firmware version: {}", properties.get(PROPERTY_FIRMWARE_VERSION));

View File

@ -16,6 +16,7 @@ import static org.openhab.binding.pentair.internal.PentairBindingConstants.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Objects;
import org.openhab.binding.pentair.internal.PentairBindingConstants; import org.openhab.binding.pentair.internal.PentairBindingConstants;
import org.openhab.binding.pentair.internal.PentairPacket; import org.openhab.binding.pentair.internal.PentairPacket;
@ -454,7 +455,7 @@ public class PentairEasyTouchHandler extends PentairBaseThingHandler {
} }
break; break;
case EASYTOUCH_SPAHEATMODESTR: case EASYTOUCH_SPAHEATMODESTR:
if (phsp == null || (phsp.spaheatmodestr != phspcur.spaheatmodestr)) { if (phsp == null || (!Objects.equals(phsp.spaheatmodestr, phspcur.spaheatmodestr))) {
if (phspcur.spaheatmodestr != null) { if (phspcur.spaheatmodestr != null) {
updateState(channel, new StringType(phspcur.spaheatmodestr)); updateState(channel, new StringType(phspcur.spaheatmodestr));
} }
@ -466,7 +467,7 @@ public class PentairEasyTouchHandler extends PentairBaseThingHandler {
} }
break; break;
case EASYTOUCH_POOLHEATMODESTR: case EASYTOUCH_POOLHEATMODESTR:
if (phsp == null || (phsp.poolheatmodestr != phspcur.poolheatmodestr)) { if (phsp == null || (!Objects.equals(phsp.poolheatmodestr, phspcur.poolheatmodestr))) {
if (phspcur.poolheatmodestr != null) { if (phspcur.poolheatmodestr != null) {
updateState(channel, new StringType(phspcur.poolheatmodestr)); updateState(channel, new StringType(phspcur.poolheatmodestr));
} }

View File

@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -177,7 +178,7 @@ public class PLCBridgeHandler extends BaseBridgeHandler {
for (Integer key : states.keySet()) { for (Integer key : states.keySet()) {
String message = states.get(buffer[0] & key.intValue()); String message = states.get(buffer[0] & key.intValue());
synchronized (oldValues) { synchronized (oldValues) {
if ((message != null) && (oldValues.get(channelUID) != message)) { if (message != null && !Objects.equals(oldValues.get(channelUID), message)) {
updateState(channelUID, new StringType(message)); updateState(channelUID, new StringType(message));
oldValues.put(channelUID, message); oldValues.put(channelUID, message);
} }
@ -187,7 +188,7 @@ public class PLCBridgeHandler extends BaseBridgeHandler {
} else if (DAY_OF_WEEK_CHANNEL.equals(channelId)) { } else if (DAY_OF_WEEK_CHANNEL.equals(channelId)) {
String value = DAY_OF_WEEK.get(Integer.valueOf(buffer[0])); String value = DAY_OF_WEEK.get(Integer.valueOf(buffer[0]));
synchronized (oldValues) { synchronized (oldValues) {
if ((value != null) && (oldValues.get(channelUID) != value)) { if (value != null && !Objects.equals(oldValues.get(channelUID), value)) {
updateState(channelUID, new StringType(value)); updateState(channelUID, new StringType(value));
oldValues.put(channelUID, value); oldValues.put(channelUID, value);
} }

View File

@ -287,7 +287,7 @@ public abstract class AbstractPlugwiseThingHandler extends BaseThingHandler impl
protected void updateTask(PlugwiseDeviceTask task) { protected void updateTask(PlugwiseDeviceTask task) {
if (task.shouldBeScheduled()) { if (task.shouldBeScheduled()) {
if (!task.isScheduled() || task.getConfiguredInterval() != task.getInterval()) { if (!task.isScheduled() || !task.getConfiguredInterval().equals(task.getInterval())) {
if (task.isScheduled()) { if (task.isScheduled()) {
task.stop(); task.stop();
} }

View File

@ -262,7 +262,7 @@ public class PlugwiseStickHandler extends BaseBridgeHandler implements PlugwiseM
protected void updateTask(PlugwiseDeviceTask task) { protected void updateTask(PlugwiseDeviceTask task) {
if (task.shouldBeScheduled()) { if (task.shouldBeScheduled()) {
if (!task.isScheduled() || task.getConfiguredInterval() != task.getInterval()) { if (!task.isScheduled() || !task.getConfiguredInterval().equals(task.getInterval())) {
if (task.isScheduled()) { if (task.isScheduled()) {
task.stop(); task.stop();
} }

View File

@ -244,7 +244,7 @@ public class QbusDimmerHandler extends QbusGlobalHandler {
} }
} else if (command instanceof PercentType) { } else if (command instanceof PercentType) {
int percentToInt = ((PercentType) command).intValue(); int percentToInt = ((PercentType) command).intValue();
if (command == PercentType.ZERO) { if (PercentType.ZERO.equals(command)) {
qDimmer.execute(0, snr); qDimmer.execute(0, snr);
} else { } else {
qDimmer.execute(percentToInt, snr); qDimmer.execute(percentToInt, snr);

View File

@ -218,7 +218,7 @@ public class QbusRolHandler extends QbusGlobalHandler {
} else if (command instanceof PercentType) { } else if (command instanceof PercentType) {
PercentType p = (PercentType) command; PercentType p = (PercentType) command;
int pp = p.intValue(); int pp = p.intValue();
if (p == PercentType.ZERO) { if (PercentType.ZERO.equals(p)) {
qRol.execute(0, snr); qRol.execute(0, snr);
} else { } else {
qRol.execute(pp, snr); qRol.execute(pp, snr);
@ -264,7 +264,7 @@ public class QbusRolHandler extends QbusGlobalHandler {
} }
} else if (command instanceof PercentType) { } else if (command instanceof PercentType) {
int percentToInt = ((PercentType) command).intValue(); int percentToInt = ((PercentType) command).intValue();
if (command == PercentType.ZERO) { if (PercentType.ZERO.equals(command)) {
qRol.executeSlats(0, snr); qRol.executeSlats(0, snr);
} else { } else {
qRol.executeSlats(percentToInt, snr); qRol.executeSlats(percentToInt, snr);

View File

@ -61,6 +61,7 @@ public class SatelOutputHandler extends WirelessChannelsHandler {
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
protected StateType getStateType(String channelId) { protected StateType getStateType(String channelId) {
StateType result = super.getStateType(channelId); StateType result = super.getStateType(channelId);
if (result == StateType.NONE) { if (result == StateType.NONE) {

View File

@ -90,6 +90,7 @@ public abstract class SatelStateThingHandler extends SatelThingHandler {
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void incomingEvent(IntegraStateEvent event) { public void incomingEvent(IntegraStateEvent event) {
logger.trace("Handling incoming event: {}", event); logger.trace("Handling incoming event: {}", event);
// update thing's state unless it should accept commands only // 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 * @param event list of state changes since last refresh
* @return collection of {@link IntegraStateCommand} * @return collection of {@link IntegraStateCommand}
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
protected Collection<SatelCommand> getRefreshCommands(NewStatesEvent event) { protected Collection<SatelCommand> getRefreshCommands(NewStatesEvent event) {
final boolean hasExtPayload = getBridgeHandler().getIntegraType().hasExtPayload(); final boolean hasExtPayload = getBridgeHandler().getIntegraType().hasExtPayload();
final Collection<SatelCommand> result = new LinkedList<>(); final Collection<SatelCommand> result = new LinkedList<>();

View File

@ -75,6 +75,7 @@ public class SatelZoneHandler extends WirelessChannelsHandler {
} }
@Override @Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
protected StateType getStateType(String channelId) { protected StateType getStateType(String channelId) {
StateType result = super.getStateType(channelId); StateType result = super.getStateType(channelId);
if (result == StateType.NONE) { if (result == StateType.NONE) {

View File

@ -421,7 +421,7 @@ public class SensiboSkyHandler extends SensiboBaseThingHandler implements Channe
case TARGET_TEMPERATURE_PROPERTY: case TARGET_TEMPERATURE_PROPERTY:
Unit<Temperature> temperatureUnit = sensiboSky.getTemperatureUnit(); Unit<Temperature> temperatureUnit = sensiboSky.getTemperatureUnit();
TemperatureDTO validTemperatures = currentModeCapabilities.temperatures TemperatureDTO validTemperatures = currentModeCapabilities.temperatures
.get(temperatureUnit == SIUnits.CELSIUS ? "C" : "F"); .get(SIUnits.CELSIUS.equals(temperatureUnit) ? "C" : "F");
DecimalType rawValue = (DecimalType) newPropertyValue; DecimalType rawValue = (DecimalType) newPropertyValue;
stateChange.updateValue(rawValue.intValue()); stateChange.updateValue(rawValue.intValue());
if (!validTemperatures.validValues.contains(rawValue.intValue())) { if (!validTemperatures.validValues.contains(rawValue.intValue())) {

View File

@ -2541,6 +2541,7 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
} }
} }
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public boolean publicAddress(LineInType lineInType) { public boolean publicAddress(LineInType lineInType) {
// check if sourcePlayer has a line-in connected // check if sourcePlayer has a line-in connected
if ((lineInType != LineInType.DIGITAL && isAnalogLineInConnected()) if ((lineInType != LineInType.DIGITAL && isAnalogLineInConnected())

View File

@ -124,7 +124,7 @@ public class ValloxMVHandler extends BaseThingHandler {
// Not writable channel // Not writable channel
return; return;
} }
if (strUpdateValue != "") { if (!strUpdateValue.isEmpty()) {
if (readDataJob != null) { if (readDataJob != null) {
// Re-schedule readDataJob to read device values after data write // Re-schedule readDataJob to read device values after data write
// Avoid re-scheduling job several times in case of subsequent data writes // Avoid re-scheduling job several times in case of subsequent data writes

View File

@ -68,6 +68,7 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService implements R
// Private // Private
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private void updateLocalization() { private void updateLocalization() {
if (localization == Localization.UNKNOWN && localeProvider != null && i18nProvider != null) { if (localization == Localization.UNKNOWN && localeProvider != null && i18nProvider != null) {
logger.trace("updateLocalization(): creating Localization based on locale={},translation={}).", logger.trace("updateLocalization(): creating Localization based on locale={},translation={}).",

View File

@ -125,6 +125,7 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory {
}); });
} }
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private void updateLocalization() { private void updateLocalization() {
if (localization == Localization.UNKNOWN && localeProvider != null && i18nProvider != null) { if (localization == Localization.UNKNOWN && localeProvider != null && i18nProvider != null) {
logger.trace("updateLocalization(): creating Localization based on locale={},translation={}).", logger.trace("updateLocalization(): creating Localization based on locale={},translation={}).",

View File

@ -129,6 +129,7 @@ final class ChannelActuatorPosition extends ChannelHandlerTemplate {
* information for this channel. * information for this channel.
* @return newValue ... * @return newValue ...
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
static @Nullable Command handleCommand(ChannelUID channelUID, String channelId, Command command, static @Nullable Command handleCommand(ChannelUID channelUID, String channelId, Command command,
VeluxBridgeHandler thisBridgeHandler) { VeluxBridgeHandler thisBridgeHandler) {
LOGGER.debug("handleCommand({},{},{},{}) called.", channelUID, channelId, command, thisBridgeHandler); LOGGER.debug("handleCommand({},{},{},{}) called.", channelUID, channelId, command, thisBridgeHandler);

View File

@ -107,6 +107,7 @@ final class ChannelVShutterPosition extends ChannelHandlerTemplate {
* information for this channel. * information for this channel.
* @return newValue ... * @return newValue ...
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
static @Nullable Command handleCommand(ChannelUID channelUID, String channelId, Command command, static @Nullable Command handleCommand(ChannelUID channelUID, String channelId, Command command,
VeluxBridgeHandler thisBridgeHandler) { VeluxBridgeHandler thisBridgeHandler) {
LOGGER.debug("handleCommand({},{},{},{}) called.", channelUID, channelId, command, thisBridgeHandler); LOGGER.debug("handleCommand({},{},{},{}) called.", channelUID, channelId, command, thisBridgeHandler);

View File

@ -135,6 +135,7 @@ public class Thing2VeluxActuator {
* *
* @return <b>bridgeProductIndex</B> for accessing the Velux device (or ProductBridgeIndex.UNKNOWN if not found). * @return <b>bridgeProductIndex</B> for accessing the Velux device (or ProductBridgeIndex.UNKNOWN if not found).
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public ProductBridgeIndex getProductBridgeIndex() { public ProductBridgeIndex getProductBridgeIndex() {
if (thisProduct == VeluxProduct.UNKNOWN) { if (thisProduct == VeluxProduct.UNKNOWN) {
mapThing2Velux(); mapThing2Velux();
@ -151,6 +152,7 @@ public class Thing2VeluxActuator {
* *
* @return <b>isKnown</B> as boolean. * @return <b>isKnown</B> as boolean.
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public boolean isKnown() { public boolean isKnown() {
return (!(this.getProductBridgeIndex() == ProductBridgeIndex.UNKNOWN)); return (!(this.getProductBridgeIndex() == ProductBridgeIndex.UNKNOWN));
} }
@ -162,6 +164,7 @@ public class Thing2VeluxActuator {
* *
* @return <b>isInverted</B> for handling of values of the Velux device (or false if not found).. * @return <b>isInverted</B> for handling of values of the Velux device (or false if not found)..
*/ */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public boolean isInverted() { public boolean isInverted() {
if (thisProduct == VeluxProduct.UNKNOWN) { if (thisProduct == VeluxProduct.UNKNOWN) {
mapThing2Velux(); mapThing2Velux();

View File

@ -159,7 +159,7 @@ public class VentaThingHandler extends BaseThingHandler {
if (config.macAddress.isEmpty()) { if (config.macAddress.isEmpty()) {
return "Mac Address not set, use discovery to find the correct one"; 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"; return "Device Type not set, use discovery to find the correct one";
} }
if (config.pollingTime.compareTo(BigDecimal.ZERO) <= 0) { if (config.pollingTime.compareTo(BigDecimal.ZERO) <= 0) {

View File

@ -318,7 +318,7 @@ public class WLedHandler extends BaseThingHandler {
} }
} }
} else if (command instanceof HSBType) { } else if (command instanceof HSBType) {
if ((((HSBType) command).getBrightness()) == PercentType.ZERO) { if (PercentType.ZERO.equals(((HSBType) command).getBrightness())) {
sendGetRequest("/win&TT=500&T=0"); sendGetRequest("/win&TT=500&T=0");
} }
primaryColor = (HSBType) command; primaryColor = (HSBType) command;

View File

@ -87,7 +87,7 @@ public class HueEmulationService implements EventHandler {
* Jetty returns 415 on any GET request if a client sends the Content-Type header. * 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. * 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().containsKey(HttpHeader.CONTENT_TYPE.asString())) {
requestContext.getHeaders().remove(HttpHeader.CONTENT_TYPE.asString()); requestContext.getHeaders().remove(HttpHeader.CONTENT_TYPE.asString());
} }

View File

@ -14,6 +14,7 @@ package org.openhab.persistence.jdbc.dto;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.Objects;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -140,7 +141,7 @@ public class ItemVO implements Serializable {
} else if (!value.equals(other.value)) { } else if (!value.equals(other.value)) {
return false; return false;
} }
return time == other.time; return Objects.equals(time, other.time);
} }
@Override @Override

View File

@ -82,7 +82,7 @@ public class MacTTSVoiceTest {
*/ */
@Test @Test
public void getLocaleTest() throws IOException { 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 ?"); Process process = Runtime.getRuntime().exec("say -v ?");
try (InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream()); try (InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream());
BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {

View File

@ -80,9 +80,9 @@ public final class WWNDataUtil {
public static String fromFile(String fileName, Unit<Temperature> temperatureUnit) throws IOException { public static String fromFile(String fileName, Unit<Temperature> temperatureUnit) throws IOException {
String json = fromFile(fileName); String json = fromFile(fileName);
if (temperatureUnit == SIUnits.CELSIUS) { if (SIUnits.CELSIUS.equals(temperatureUnit)) {
json = json.replace("\"temperature_scale\": \"F\"", "\"temperature_scale\": \"C\""); 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\""); json = json.replace("\"temperature_scale\": \"C\"", "\"temperature_scale\": \"F\"");
} }
return json; return json;