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>
/**
* Sets a new state in the state machine.
*/
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public synchronized void nextState(Function<StateMachine, ? extends State> nextState) {
if (context.getState() != this) { // compare identity
return;
* @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);
+ 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()));
}
}
}
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public boolean initialize(AccountHandler handler, String currentConfigurationJson) {
updateState(CHANNEL_SAVE, OnOffType.OFF);
if (updatePlayOnDevice) {
* 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
@Override
public void responseReceived(String response) {
- if (response == null || response == "") {
+ if (response == null || response.isEmpty()) {
return;
}
}
private boolean isJandy() {
- return getThing().getThingTypeUID() == AutelisBindingConstants.JANDY_THING_TYPE_UID;
+ return AutelisBindingConstants.JANDY_THING_TYPE_UID.equals(getThing().getThingTypeUID());
}
}
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;
return getAdapter(currentDelegateRef.get());
}
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
private class Listener implements BluetoothDeviceListener {
private BluetoothDevice device;
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void addBluetoothAdapter(BluetoothAdapter adapter) {
if (adapter == this) {
return;
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void removeBluetoothAdapter(BluetoothAdapter adapter) {
if (adapter == this) {
return;
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void dispose() {
cancel(reconnectJob, true);
reconnectJob = null;
return characteristic;
}
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
private <T> CompletableFuture<T> executeWithConnection(UUID serviceUUID, UUID characteristicUUID,
Function<BluetoothCharacteristic, CompletableFuture<T>> callable) {
if (connectionTaskExecutor == scheduler) {
return new HeritableFuture<>(this);
}
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
protected void setParentFuture(Supplier<@Nullable Future<?>> futureSupplier) {
synchronized (futureLock) {
var future = futureSupplier.get();
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<String> codeChallenge = getTokenBaseValues();
codeChallenge.put(AUTHORIZATION, authCode);
* @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;
List<Channel> channels = getThing().getChannels();
for (Channel ch : channels) {
- if (channelUID == ch.getUID()) {
+ if (channelUID.equals(ch.getUID())) {
channel = ch;
break;
}
* 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;
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;
}
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);
// 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())) {
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);
} 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);
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)));
}
List<Channel> channels = getThing().getChannels();
for (Channel ch : channels) {
- if (channelUID == ch.getUID()) {
+ if (ch.getUID().equals(channelUID)) {
channel = ch;
break;
}
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) {
* @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, "");
}
/**
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, "");
}
}
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void dscAlarmEventReceived(EventObject event, Thing thing) {
if (thing != null) {
DSCAlarmEvent dscAlarmEvent = (DSCAlarmEvent) event;
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void dscAlarmEventReceived(EventObject event, Thing thing) {
if (thing != null) {
if (getThing() == thing) {
/**
* 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.
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.
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;
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;
}
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public int compareTo(Delayed delayed) {
if (delayed == this) {
return 0;
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public int compareTo(Delayed delayed) {
if (delayed == this) {
return 0;
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));
}
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void run() {
PortData currentData = portDatas.get(port);
if (currentData != null && currentData.getValue() == 1 && currentData.getTimestamp() == referenceTime) {
* @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;
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;
// 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");
}
// 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 {
List<String> 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 {
*
* @param next is the sister datapoint
*/
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void append(HeliosVentilationDataPoint next) {
HeliosVentilationDataPoint existing = this.next;
if (this == next) {
@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;
}
/**
@Override
protected OpenClosedType fromBinding(HmDatapoint dp) throws ConverterException {
- return (((Boolean) dp.getValue()) == Boolean.FALSE) != isInvert(dp) ? OpenClosedType.CLOSED
- : OpenClosedType.OPEN;
+ return Boolean.FALSE.equals(dp.getValue()) != isInvert(dp) ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
}
/**
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;
* 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);
}
/**
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%");
Optional<Auxiliary> 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);
}
}
}
}
} 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<OneTouch> 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);
}
* @return
*/
public boolean hasSerialNumber() {
- return (serialnumber != null && serialnumber != "");
+ return serialnumber != null && !serialnumber.isEmpty();
}
/**
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());
}
//
* @param msg
* @return true;
*/
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
boolean isMyDirectAck(Msg msg) {
return msg.isAckOfDirect() && (feature.getQueryStatus() == DeviceFeature.QueryStatus.QUERY_PENDING)
&& feature.getDevice().getFeatureQueried() == feature;
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void userEventTriggered(@Nullable ChannelHandlerContext ctx, @Nullable Object evt) throws Exception {
if (ctx == null) {
return;
* 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;
// 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());
// 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());
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);
}
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);
}
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
protected void startScan() {
synchronized (this) {
PckGatewayHandler localBridgeHandler = bridgeHandler;
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void handleStatusMessage(Matcher matcher) throws LcnException {
Variable variable;
if (matcher.pattern() == PATTERN) {
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void handleStatusMessage(Matcher matcher) throws LcnException {
Variable variable;
if (matcher.pattern() == PATTERN) {
*/
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;
}
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
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);
}
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) {
}
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);
Value value;
Boolean isDecimal = null;
- if (attributes.name == "") {
+ if (attributes.name.isEmpty()) {
attributes.name = propertyID;
}
* is no connection established yet.
*/
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public void brokerAdded(String connectionName, MqttBrokerConnection addedConnection) {
if (!connectionName.equals(brokerID) || connection == addedConnection) {
return;
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();
}
}
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));
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);
});
} 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);
}
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;
Map<String, Object> 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 + ")";
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;
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));
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;
}
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));
}
}
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));
}
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;
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);
}
} 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);
}
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();
}
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();
}
}
} 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);
} 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);
}
} 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);
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
protected StateType getStateType(String channelId) {
StateType result = super.getStateType(channelId);
if (result == StateType.NONE) {
}
@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
* @param event list of state changes since last refresh
* @return collection of {@link IntegraStateCommand}
*/
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
protected Collection<SatelCommand> getRefreshCommands(NewStatesEvent event) {
final boolean hasExtPayload = getBridgeHandler().getIntegraType().hasExtPayload();
final Collection<SatelCommand> result = new LinkedList<>();
}
@Override
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
protected StateType getStateType(String channelId) {
StateType result = super.getStateType(channelId);
if (result == StateType.NONE) {
case TARGET_TEMPERATURE_PROPERTY:
Unit<Temperature> 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())) {
}
}
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public boolean publicAddress(LineInType lineInType) {
// check if sourcePlayer has a line-in connected
if ((lineInType != LineInType.DIGITAL && isAnalogLineInConnected())
// 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
// Private
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
private void updateLocalization() {
if (localization == Localization.UNKNOWN && localeProvider != null && i18nProvider != null) {
logger.trace("updateLocalization(): creating Localization based on locale={},translation={}).",
});
}
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
private void updateLocalization() {
if (localization == Localization.UNKNOWN && localeProvider != null && i18nProvider != null) {
logger.trace("updateLocalization(): creating Localization based on locale={},translation={}).",
* 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);
* 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);
*
* @return <b>bridgeProductIndex</B> for accessing the Velux device (or ProductBridgeIndex.UNKNOWN if not found).
*/
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public ProductBridgeIndex getProductBridgeIndex() {
if (thisProduct == VeluxProduct.UNKNOWN) {
mapThing2Velux();
*
* @return <b>isKnown</B> as boolean.
*/
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public boolean isKnown() {
return (!(this.getProductBridgeIndex() == ProductBridgeIndex.UNKNOWN));
}
*
* @return <b>isInverted</B> for handling of values of the Velux device (or false if not found)..
*/
+ @SuppressWarnings("PMD.CompareObjectsWithEquals")
public boolean isInverted() {
if (thisProduct == VeluxProduct.UNKNOWN) {
mapThing2Velux();
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) {
}
}
} 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;
* 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());
}
import java.io.Serializable;
import java.util.Date;
+import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
} else if (!value.equals(other.value)) {
return false;
}
- return time == other.time;
+ return Objects.equals(time, other.time);
}
@Override
*/
@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)) {
public static String fromFile(String fileName, Unit<Temperature> 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;