Fix SAT warnings (#14202)

* Fix SAT warnings

- checkstyle.ModifierOrderCheck
- checkstyle.OneStatementPerLineCheck
- checkstyle.NeedBracesCheck
- PMD.UseStandardCharsets
- PMD.UseCollectionIsEmpty
- PMD.UnusedLocalVariable
- PMD.SimplifyBooleanReturns where reasonable, suppress where
readability is better without change
- PMD.SimplifyBooleanExpressions

* Include StandardCharsets

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich 2023-01-13 08:11:06 +01:00 committed by GitHub
parent 6aa0dcbc70
commit 4e44de3894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
86 changed files with 148 additions and 157 deletions

View File

@ -165,6 +165,7 @@ public class BluetoothDeviceSnapshot extends BluetoothDiscoveryDevice {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -57,8 +57,9 @@ public abstract class AbstractStatelessBoschSHCService extends AbstractBoschSHCS
*/ */
public void postAction() throws InterruptedException, TimeoutException, ExecutionException { public void postAction() throws InterruptedException, TimeoutException, ExecutionException {
BridgeHandler bridgeHandler = getBridgeHandler(); BridgeHandler bridgeHandler = getBridgeHandler();
if (bridgeHandler == null) if (bridgeHandler == null) {
return; return;
}
bridgeHandler.postAction(endpoint); bridgeHandler.postAction(endpoint);
} }

View File

@ -127,6 +127,7 @@ public class X10ReceivedData {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -392,7 +392,7 @@ public class LightThingHandler extends DeconzBaseThingHandler {
} }
break; break;
case CHANNEL_COLOR: case CHANNEL_COLOR:
if (on != null && on == false) { if (on != null && !on) {
updateState(channelId, OnOffType.OFF); updateState(channelId, OnOffType.OFF);
} else if (bri != null && "xy".equals(newState.colormode)) { } else if (bri != null && "xy".equals(newState.colormode)) {
final double @Nullable [] xy = newState.xy; final double @Nullable [] xy = newState.xy;

View File

@ -113,11 +113,7 @@ public class DigiplexResponseResolver {
} }
private static boolean toBoolean(char value) { private static boolean toBoolean(char value) {
if (value == 'O') { return value != 'O';
return false;
} else {
return true;
}
} }
private static DigiplexResponse resolveSystemEvent(String message) { private static DigiplexResponse resolveSystemEvent(String message) {

View File

@ -41,9 +41,6 @@ public abstract class AbstractEvent implements DigiplexResponse {
// TODO: According to documentation: areaNo = 255 - Occurs in at least one area enabled in the system. // TODO: According to documentation: areaNo = 255 - Occurs in at least one area enabled in the system.
// I did never encounter 255 on my system though (EVO192). // I did never encounter 255 on my system though (EVO192).
// 15 is returned instead, which (I believe) has the same meaning. // 15 is returned instead, which (I believe) has the same meaning.
if (this.areaNo == 15 || this.areaNo == 255) { return (this.areaNo == 15 || this.areaNo == 255);
return true;
}
return false;
} }
} }

View File

@ -101,11 +101,7 @@ public class DigiplexDiscoveryService extends AbstractDiscoveryService
private boolean isDefaultName(ZoneLabelResponse response) { private boolean isDefaultName(ZoneLabelResponse response) {
return ZONE_DEFAULT_NAMES.stream().anyMatch(format -> { return ZONE_DEFAULT_NAMES.stream().anyMatch(format -> {
if (String.format(format, response.zoneNo).equals(response.zoneName)) { return String.format(format, response.zoneNo).equals(response.zoneName);
return true;
} else {
return false;
}
}); });
} }

View File

@ -83,6 +83,7 @@ public class AssignSensorType {
* *
* @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#equals(java.lang.Object)
*/ */
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -267,6 +267,7 @@ public class DeviceSensorValue {
* *
* @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#equals(java.lang.Object)
*/ */
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -33,13 +33,7 @@ public class Util {
* @return true or false * @return true or false
*/ */
public static boolean inRange(int value, int min, int max) { public static boolean inRange(int value, int min, int max) {
if (value < min) { return value >= min && value <= max;
return false;
}
if (value > max) {
return false;
}
return true;
} }
/** /**

View File

@ -380,7 +380,6 @@ public class PanelThingHandler extends DSCAlarmBaseThingHandler {
String[] channelTypes = { PANEL_SERVICE_REQUIRED, PANEL_AC_TROUBLE, PANEL_TELEPHONE_TROUBLE, PANEL_FTC_TROUBLE, String[] channelTypes = { PANEL_SERVICE_REQUIRED, PANEL_AC_TROUBLE, PANEL_TELEPHONE_TROUBLE, PANEL_FTC_TROUBLE,
PANEL_ZONE_FAULT, PANEL_ZONE_TAMPER, PANEL_ZONE_LOW_BATTERY, PANEL_TIME_LOSS }; PANEL_ZONE_FAULT, PANEL_ZONE_TAMPER, PANEL_ZONE_LOW_BATTERY, PANEL_TIME_LOSS };
String channel;
ChannelUID channelUID = null; ChannelUID channelUID = null;
int bitCount = 8; int bitCount = 8;

View File

@ -40,12 +40,8 @@ public class A5_11_03 extends _4BSMessage {
int state = (db1 >> 4) & 0x03; int state = (db1 >> 4) & 0x03;
if (state != 0) { // TODO: display error state on thing
// TODO: display error state on thing return state != 0;
return true;
} else {
return false;
}
} }
protected State getPositionData() { protected State getPositionData() {

View File

@ -49,7 +49,7 @@ public class ESP3PacketFactory {
new byte[] { SAMessageType.SA_WR_LEARNMODE.getValue(), (byte) (activate ? 1 : 0), 0, 0, 0, 0, 0 }); new byte[] { SAMessageType.SA_WR_LEARNMODE.getValue(), (byte) (activate ? 1 : 0), 0, 0, 0, 0, 0 });
} }
public final static BasePacket SA_RD_LEARNEDCLIENTS = new SAMessage(SAMessageType.SA_RD_LEARNEDCLIENTS); public static final BasePacket SA_RD_LEARNEDCLIENTS = new SAMessage(SAMessageType.SA_RD_LEARNEDCLIENTS);
public static BasePacket SA_RD_MAILBOX_STATUS(byte[] clientId, byte[] controllerId) { public static BasePacket SA_RD_MAILBOX_STATUS(byte[] clientId, byte[] controllerId) {
return new SAMessage(SAMessageType.SA_RD_MAILBOX_STATUS, return new SAMessage(SAMessageType.SA_RD_MAILBOX_STATUS,

View File

@ -196,7 +196,7 @@ public class EnturNoConnection {
.collect(groupingBy(call -> call.quay.id)); .collect(groupingBy(call -> call.quay.id));
List<DisplayData> processedData = new ArrayList<>(); List<DisplayData> processedData = new ArrayList<>();
if (departures.keySet().size() > 0) { if (!departures.keySet().isEmpty()) {
DisplayData processedData01 = getDisplayData(stopPlace, departures, 0); DisplayData processedData01 = getDisplayData(stopPlace, departures, 0);
processedData.add(processedData01); processedData.add(processedData01);
} }

View File

@ -348,8 +348,9 @@ public enum Measurand {
} }
public MeasureType getMeasureType(@Nullable ParserCustomizationType customizationType) { public MeasureType getMeasureType(@Nullable ParserCustomizationType customizationType) {
if (customizationType == null) if (customizationType == null) {
return measureType; return measureType;
}
return Optional.ofNullable(customizations).map(m -> m.get(customizationType)) return Optional.ofNullable(customizations).map(m -> m.get(customizationType))
.map(ParserCustomization::getMeasureType).orElse(measureType); .map(ParserCustomization::getMeasureType).orElse(measureType);
} }

View File

@ -38,7 +38,7 @@ public class FroniusHttpUtil {
* @return the response body * @return the response body
* @throws FroniusCommunicationException when the request execution failed or interrupted * @throws FroniusCommunicationException when the request execution failed or interrupted
*/ */
public synchronized static String executeUrl(String url, int timeout) throws FroniusCommunicationException { public static synchronized String executeUrl(String url, int timeout) throws FroniusCommunicationException {
int attemptCount = 1; int attemptCount = 1;
try { try {
while (true) { while (true) {

View File

@ -821,10 +821,7 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
BigDecimal port = (BigDecimal) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PORT.toString()); BigDecimal port = (BigDecimal) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PORT.toString());
String pin = (String) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PIN.toString()); String pin = (String) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PIN.toString());
if (ip == null || port.compareTo(BigDecimal.ZERO) == 0 || pin == null || pin.isEmpty()) { return !(ip == null || port.compareTo(BigDecimal.ZERO) == 0 || pin == null || pin.isEmpty());
return false;
}
return true;
} }
@SuppressWarnings("null") @SuppressWarnings("null")

View File

@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
public class Device { public class Device {
private final Logger logger = LoggerFactory.getLogger(Device.class); private final Logger logger = LoggerFactory.getLogger(Device.class);
private transient static final String DEVICE_TYPE_PREFIX = "gardena smart"; private static final transient String DEVICE_TYPE_PREFIX = "gardena smart";
public boolean active = true; public boolean active = true;
public String id; public String id;
public String deviceType; public String deviceType;

View File

@ -443,10 +443,10 @@ public class GlobalCacheHandler extends BaseThingHandler {
private Logger logger = LoggerFactory.getLogger(CommandProcessor.class); private Logger logger = LoggerFactory.getLogger(CommandProcessor.class);
private boolean terminate = false; private boolean terminate = false;
private final String TERMINATE_COMMAND = "terminate"; private static final String TERMINATE_COMMAND = "terminate";
private final int SEND_QUEUE_MAX_DEPTH = 10; private static final int SEND_QUEUE_MAX_DEPTH = 10;
private final int SEND_QUEUE_TIMEOUT = 2000; private static final int SEND_QUEUE_TIMEOUT = 2000;
private ConnectionManager connectionManager; private ConnectionManager connectionManager;
@ -594,19 +594,19 @@ public class GlobalCacheHandler extends BaseThingHandler {
private boolean deviceIsConnected; private boolean deviceIsConnected;
private final String COMMAND_NAME = "command"; private static final String COMMAND_NAME = "command";
private final String SERIAL1_NAME = "serial-1"; private static final String SERIAL1_NAME = "serial-1";
private final String SERIAL2_NAME = "serial-2"; private static final String SERIAL2_NAME = "serial-2";
private final int COMMAND_PORT = 4998; private static final int COMMAND_PORT = 4998;
private final int SERIAL1_PORT = 4999; private static final int SERIAL1_PORT = 4999;
private final int SERIAL2_PORT = 5000; private static final int SERIAL2_PORT = 5000;
private final int SOCKET_CONNECT_TIMEOUT = 1500; private static final int SOCKET_CONNECT_TIMEOUT = 1500;
private ScheduledFuture<?> connectionMonitorJob; private ScheduledFuture<?> connectionMonitorJob;
private final int CONNECTION_MONITOR_FREQUENCY = 60; private static final int CONNECTION_MONITOR_FREQUENCY = 60;
private final int CONNECTION_MONITOR_START_DELAY = 15; private static final int CONNECTION_MONITOR_START_DELAY = 15;
private Runnable connectionMonitorRunnable = () -> { private Runnable connectionMonitorRunnable = () -> {
logger.trace("Performing connection check for thing {} at IP {}", thingID(), commandConnection.getIP()); logger.trace("Performing connection check for thing {} at IP {}", thingID(), commandConnection.getIP());
@ -844,10 +844,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
} }
private boolean deviceSupportsSerialPort2() { private boolean deviceSupportsSerialPort2() {
if (thing.getThingTypeUID().equals(THING_TYPE_GC_100_12)) { return thing.getThingTypeUID().equals(THING_TYPE_GC_100_12);
return true;
}
return false;
} }
/* /*

View File

@ -68,6 +68,7 @@ public class GoEChargerV2Handler extends GoEChargerBaseHandler {
super(thing, httpClient); super(thing, httpClient);
} }
@SuppressWarnings("PMD.SimplifyBooleanExpressions")
@Override @Override
protected State getValue(String channelId, GoEStatusResponseBaseDTO goeResponseBase) { protected State getValue(String channelId, GoEStatusResponseBaseDTO goeResponseBase) {
var state = super.getValue(channelId, goeResponseBase); var state = super.getValue(channelId, goeResponseBase);

View File

@ -66,8 +66,9 @@ public class PigpioDigitalInputHandler implements ChannelHandler {
} else if (pullupdownStr.equals(GPIOBindingConstants.PUD_UP)) { } else if (pullupdownStr.equals(GPIOBindingConstants.PUD_UP)) {
pullupdown = JPigpio.PI_PUD_UP; pullupdown = JPigpio.PI_PUD_UP;
} else { } else {
if (!pullupdownStr.equals(GPIOBindingConstants.PUD_OFF)) if (!pullupdownStr.equals(GPIOBindingConstants.PUD_OFF)) {
throw new InvalidPullUpDownException(); throw new InvalidPullUpDownException();
}
} }
gpio = new GPIO(jPigpio, gpioId, JPigpio.PI_INPUT); gpio = new GPIO(jPigpio, gpioId, JPigpio.PI_INPUT);
jPigpio.gpioSetAlertFunc(gpio.getPin(), (gpio, level, tick) -> { jPigpio.gpioSetAlertFunc(gpio.getPin(), (gpio, level, tick) -> {

View File

@ -33,7 +33,7 @@ import com.google.gson.JsonSyntaxException;
@NonNullByDefault @NonNullByDefault
public class GreeException extends Exception { public class GreeException extends Exception {
private static final long serialVersionUID = -2337258558995287405L; private static final long serialVersionUID = -2337258558995287405L;
private static String EX_NONE = "none"; private static final String EX_NONE = "none";
public GreeException(@Nullable Exception exception) { public GreeException(@Nullable Exception exception) {
super(exception); super(exception);

View File

@ -60,7 +60,7 @@ import com.google.gson.JsonSyntaxException;
@NonNullByDefault @NonNullByDefault
public class GreeAirDevice { public class GreeAirDevice {
private final Logger logger = LoggerFactory.getLogger(GreeAirDevice.class); private final Logger logger = LoggerFactory.getLogger(GreeAirDevice.class);
private final static Gson gson = new Gson(); private static final Gson gson = new Gson();
private boolean isBound = false; private boolean isBound = false;
private final InetAddress ipAddress; private final InetAddress ipAddress;
private int port = 0; private int port = 0;
@ -80,7 +80,6 @@ public class GreeAirDevice {
} }
public void getDeviceStatus(DatagramSocket clientSocket) throws GreeException { public void getDeviceStatus(DatagramSocket clientSocket) throws GreeException {
if (!isBound) { if (!isBound) {
throw new GreeException("Device not bound"); throw new GreeException("Device not bound");
} }

View File

@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault @NonNullByDefault
public class HeosActions implements ThingActions { public class HeosActions implements ThingActions {
private final static Logger logger = LoggerFactory.getLogger(HeosActions.class); private static final Logger logger = LoggerFactory.getLogger(HeosActions.class);
private @Nullable HeosBridgeHandler handler; private @Nullable HeosBridgeHandler handler;

View File

@ -43,7 +43,6 @@ public class HeosChannelHandlerGrouping extends BaseHeosChannelHandler {
@Override @Override
public void handleGroupCommand(Command command, @Nullable String id, ThingUID uid, public void handleGroupCommand(Command command, @Nullable String id, ThingUID uid,
HeosGroupHandler heosGroupHandler) throws IOException, ReadException { HeosGroupHandler heosGroupHandler) throws IOException, ReadException {
if (command instanceof RefreshType) { if (command instanceof RefreshType) {
return; return;
} }

View File

@ -278,7 +278,6 @@ public abstract class HeosThingBaseHandler extends BaseThingHandler implements H
} }
switch (command) { switch (command) {
case PLAYER_STATE_CHANGED: case PLAYER_STATE_CHANGED:
playerStateChanged(eventObject); playerStateChanged(eventObject);
break; break;

View File

@ -131,8 +131,9 @@ public abstract class RpcClient<T> {
* Disposes the client. * Disposes the client.
*/ */
public void dispose() { public void dispose() {
if (future != null) if (future != null) {
future.cancel(true); future.cancel(true);
}
} }
/** /**

View File

@ -335,7 +335,7 @@ public class HomematicTypeGeneratorImpl implements HomematicTypeGenerator {
ParameterOption defaultOption = options.get(offset); ParameterOption defaultOption = options.get(offset);
logger.trace("Changing default option to {} (offset {})", defaultOption, offset); logger.trace("Changing default option to {} (offset {})", defaultOption, offset);
builder.withDefault(defaultOption.getValue()); builder.withDefault(defaultOption.getValue());
} else if (options.size() > 0) { } else if (!options.isEmpty()) {
ParameterOption defaultOption = options.get(0); ParameterOption defaultOption = options.get(0);
logger.trace("Changing default option to {} (first value)", defaultOption); logger.trace("Changing default option to {} (first value)", defaultOption);
builder.withDefault(defaultOption.getValue()); builder.withDefault(defaultOption.getValue());

View File

@ -148,6 +148,7 @@ public class InsteonAddress {
return s; return s;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -49,13 +49,13 @@ public class KM200SwitchProgramServiceHandler {
protected final Integer MIN_TIME = 0; protected final Integer MIN_TIME = 0;
protected final Integer MAX_TIME = 1430; protected final Integer MAX_TIME = 1430;
protected final static String TYPE_MONDAY = "Mo"; protected static final String TYPE_MONDAY = "Mo";
protected final static String TYPE_TUESDAY = "Tu"; protected static final String TYPE_TUESDAY = "Tu";
protected final static String TYPE_WEDNESDAY = "We"; protected static final String TYPE_WEDNESDAY = "We";
protected final static String TYPE_THURSDAY = "Th"; protected static final String TYPE_THURSDAY = "Th";
protected final static String TYPE_FRIDAY = "Fr"; protected static final String TYPE_FRIDAY = "Fr";
protected final static String TYPE_SATURDAY = "Sa"; protected static final String TYPE_SATURDAY = "Sa";
protected final static String TYPE_SUNDAY = "Su"; protected static final String TYPE_SUNDAY = "Su";
private String activeDay = TYPE_MONDAY; private String activeDay = TYPE_MONDAY;
private Integer activeCycle = 1; private Integer activeCycle = 1;

View File

@ -244,6 +244,7 @@ public enum Variable {
* @param is2013 the target module's-generation * @param is2013 the target module's-generation
* @return true if a poll is required to get the new status-value * @return true if a poll is required to get the new status-value
*/ */
@SuppressWarnings("PMD.SimplifyBooleanReturns")
public boolean shouldPollStatusAfterCommand(int firmwareVersion) { public boolean shouldPollStatusAfterCommand(int firmwareVersion) {
// Regulator set-points will send status-messages on every change (all firmware versions) // Regulator set-points will send status-messages on every change (all firmware versions)
if (type == Type.REGULATOR) { if (type == Type.REGULATOR) {

View File

@ -30,8 +30,9 @@ public class PercentageConverter {
* @return if hexRepresentation == null return -1, otherwise return percentage * @return if hexRepresentation == null return -1, otherwise return percentage
*/ */
public static int getPercentage(@Nullable String hexRepresentation) { public static int getPercentage(@Nullable String hexRepresentation) {
if (hexRepresentation == null) if (hexRepresentation == null) {
return -1; return -1;
}
int decimal = Integer.parseInt(hexRepresentation, 16); int decimal = Integer.parseInt(hexRepresentation, 16);
BigDecimal level = new BigDecimal(100 * decimal).divide(new BigDecimal(255), RoundingMode.FLOOR); BigDecimal level = new BigDecimal(100 * decimal).divide(new BigDecimal(255), RoundingMode.FLOOR);
return level.intValue(); return level.intValue();

View File

@ -1410,11 +1410,7 @@ public enum HeatpumpChannel {
int code = visiblity.getCode(); int code = visiblity.getCode();
if (visibilityValues.length < code || visibilityValues[code] == 1) { return (visibilityValues.length < code || visibilityValues[code] == 1);
return true;
}
return false;
} }
public static HeatpumpChannel fromString(String heatpumpCommand) throws InvalidChannelException { public static HeatpumpChannel fromString(String heatpumpCommand) throws InvalidChannelException {

View File

@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault @NonNullByDefault
public class MagentaTVControl { public class MagentaTVControl {
private final Logger logger = LoggerFactory.getLogger(MagentaTVControl.class); private final Logger logger = LoggerFactory.getLogger(MagentaTVControl.class);
private final static HashMap<String, String> KEY_MAP = new HashMap<>(); private static final HashMap<String, String> KEY_MAP = new HashMap<>();
private final MagentaTVNetwork network; private final MagentaTVNetwork network;
private final MagentaTVHttp http = new MagentaTVHttp(); private final MagentaTVHttp http = new MagentaTVHttp();

View File

@ -30,8 +30,8 @@ import org.eclipse.jdt.annotation.Nullable;
@NonNullByDefault @NonNullByDefault
public class TimeStabilizer { public class TimeStabilizer {
private final static int SLIDING_SECONDS = 300; private static final int SLIDING_SECONDS = 300;
private final static int MAX_FLUCTUATION_SECONDS = 180; private static final int MAX_FLUCTUATION_SECONDS = 180;
private final Deque<Item> cache = new ConcurrentLinkedDeque<Item>(); private final Deque<Item> cache = new ConcurrentLinkedDeque<Item>();

View File

@ -55,6 +55,7 @@ public class TransitionState {
return previousState.map(this::hasFinishedChangedFromPreviousState).orElse(true); return previousState.map(this::hasFinishedChangedFromPreviousState).orElse(true);
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
private boolean hasFinishedChangedFromPreviousState(DeviceState previous) { private boolean hasFinishedChangedFromPreviousState(DeviceState previous) {
if (previous.getStateType().equals(nextState.getStateType())) { if (previous.getStateType().equals(nextState.getStateType())) {
return false; return false;

View File

@ -128,10 +128,7 @@ public class MillheatAccountHandler extends BaseBridgeHandler {
private boolean allowModelUpdate() { private boolean allowModelUpdate() {
final long timeSinceLastUpdate = System.currentTimeMillis() - model.getLastUpdated(); final long timeSinceLastUpdate = System.currentTimeMillis() - model.getLastUpdated();
if (timeSinceLastUpdate > MIN_TIME_BETWEEEN_MODEL_UPDATES_MS) { return timeSinceLastUpdate > MIN_TIME_BETWEEEN_MODEL_UPDATES_MS;
return true;
}
return false;
} }
public MillheatModel getModel() { public MillheatModel getModel() {

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.modbus.sunspec.internal.parser; package org.openhab.binding.modbus.sunspec.internal.parser;
import java.nio.charset.Charset; import java.nio.charset.StandardCharsets;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.modbus.sunspec.internal.SunSpecConstants; import org.openhab.binding.modbus.sunspec.internal.SunSpecConstants;
@ -52,10 +52,10 @@ public class CommonModelParser extends AbstractBaseParser implements SunspecPars
} }
// parse manufacturer, model and version // parse manufacturer, model and version
block.manufacturer = ModbusBitUtilities.extractStringFromRegisters(raw, 2, 32, Charset.forName("UTF-8")); block.manufacturer = ModbusBitUtilities.extractStringFromRegisters(raw, 2, 32, StandardCharsets.UTF_8);
block.model = ModbusBitUtilities.extractStringFromRegisters(raw, 18, 32, Charset.forName("UTF-8")); block.model = ModbusBitUtilities.extractStringFromRegisters(raw, 18, 32, StandardCharsets.UTF_8);
block.version = ModbusBitUtilities.extractStringFromRegisters(raw, 42, 16, Charset.forName("UTF-8")); block.version = ModbusBitUtilities.extractStringFromRegisters(raw, 42, 16, StandardCharsets.UTF_8);
block.serialNumber = ModbusBitUtilities.extractStringFromRegisters(raw, 50, 32, Charset.forName("UTF-8")); block.serialNumber = ModbusBitUtilities.extractStringFromRegisters(raw, 50, 32, StandardCharsets.UTF_8);
block.deviceAddress = extractUInt16(raw, 66, 1); block.deviceAddress = extractUInt16(raw, 66, 1);

View File

@ -903,8 +903,6 @@ public class NanoleafControllerHandler extends BaseBridgeHandler implements Nano
break; break;
case CHANNEL_COLOR_TEMPERATURE_ABS: case CHANNEL_COLOR_TEMPERATURE_ABS:
// Color temperature (absolute) // Color temperature (absolute)
int colorTempKelvin;
IntegerState state = new Ct(); IntegerState state = new Ct();
if (command instanceof DecimalType) { if (command instanceof DecimalType) {
state.setValue(((DecimalType) command).intValue()); state.setValue(((DecimalType) command).intValue());

View File

@ -78,7 +78,7 @@ public class PanelLayout {
goEquals = go.equals(otherGo); goEquals = go.equals(otherGo);
} }
if (goEquals == false) { if (!goEquals) {
// No reason to compare layout if global oriantation is different // No reason to compare layout if global oriantation is different
return false; return false;
} }

View File

@ -299,9 +299,9 @@ public class NikobusPushButtonHandler extends NikobusBaseThingHandler {
processNext(currentTimeMillis); processNext(currentTimeMillis);
} }
abstract protected void reset(long currentTimeMillis); protected abstract void reset(long currentTimeMillis);
abstract protected void processNext(long currentTimeMillis); protected abstract void processNext(long currentTimeMillis);
} }
public static class TriggerButtonConfig { public static class TriggerButtonConfig {

View File

@ -294,8 +294,8 @@ public class NikobusRollershutterModuleHandler extends NikobusModuleHandler {
final int up; final int up;
final int down; final int down;
final static DirectionConfiguration NORMAL = new DirectionConfiguration(1, 2); static final DirectionConfiguration NORMAL = new DirectionConfiguration(1, 2);
final static DirectionConfiguration REVERSED = new DirectionConfiguration(2, 1); static final DirectionConfiguration REVERSED = new DirectionConfiguration(2, 1);
private DirectionConfiguration(int up, int down) { private DirectionConfiguration(int up, int down) {
this.up = up; this.up = up;

View File

@ -90,10 +90,10 @@ public class OnkyoBindingConstants {
public static final String CHANNEL_NET_MENU8 = "netmenu#item8"; public static final String CHANNEL_NET_MENU8 = "netmenu#item8";
public static final String CHANNEL_NET_MENU9 = "netmenu#item9"; public static final String CHANNEL_NET_MENU9 = "netmenu#item9";
public final static String CHANNEL_AUDIO_IN_INFO = "info#audioIn"; public static final String CHANNEL_AUDIO_IN_INFO = "info#audioIn";
public final static String CHANNEL_AUDIO_OUT_INFO = "info#audioOut"; public static final String CHANNEL_AUDIO_OUT_INFO = "info#audioOut";
public final static String CHANNEL_VIDEO_IN_INFO = "info#videoIn"; public static final String CHANNEL_VIDEO_IN_INFO = "info#videoIn";
public final static String CHANNEL_VIDEO_OUT_INFO = "info#videoOut"; public static final String CHANNEL_VIDEO_OUT_INFO = "info#videoOut";
// Used for Discovery service // Used for Discovery service
public static final String MANUFACTURER = "ONKYO"; public static final String MANUFACTURER = "ONKYO";

View File

@ -32,7 +32,7 @@ public enum PartitionCommand {
DISARM(6), DISARM(6),
BEEP(8); BEEP(8);
private final static Logger logger = LoggerFactory.getLogger(PartitionCommand.class); private static final Logger logger = LoggerFactory.getLogger(PartitionCommand.class);
private int command; private int command;

View File

@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
public class ParadoxUtil { public class ParadoxUtil {
private static final String SPACE_DELIMITER = " "; private static final String SPACE_DELIMITER = " ";
private final static Logger logger = LoggerFactory.getLogger(ParadoxUtil.class); private static final Logger logger = LoggerFactory.getLogger(ParadoxUtil.class);
public static byte calculateChecksum(byte[] payload) { public static byte calculateChecksum(byte[] payload) {
int result = 0; int result = 0;

View File

@ -41,7 +41,7 @@ public class TestGetBytes {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "TRACE"); System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "TRACE");
} }
private final static Logger logger = LoggerFactory.getLogger(ParadoxUtil.class); private static final Logger logger = LoggerFactory.getLogger(ParadoxUtil.class);
private static final byte[] EXPECTED1 = { (byte) 0xAA, 0x0A, 0x00, 0x03, 0x08, (byte) 0xF0, 0x00, 0x00, 0x01, private static final byte[] EXPECTED1 = { (byte) 0xAA, 0x0A, 0x00, 0x03, 0x08, (byte) 0xF0, 0x00, 0x00, 0x01,
(byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, 0x01, 0x02, 0x03, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, 0x01, 0x02, 0x03,

View File

@ -73,6 +73,7 @@ public class Input {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -37,6 +37,7 @@ public class MACAddress {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -308,6 +308,7 @@ public class ResolThingHandler extends ResolBaseThingHandler {
} }
/* check if the given value is a special one like 888.8 or 999.9 for shortcut or open load on a sensor wire */ /* check if the given value is a special one like 888.8 or 999.9 for shortcut or open load on a sensor wire */
@SuppressWarnings("PMD.SimplifyBooleanReturns")
private boolean isSpecialValue(Double dd) { private boolean isSpecialValue(Double dd) {
if ((Math.abs(dd - 888.8) < 0.1) || (Math.abs(dd - (-888.8)) < 0.1)) { if ((Math.abs(dd - 888.8) < 0.1) || (Math.abs(dd - (-888.8)) < 0.1)) {
/* value out of range */ /* value out of range */

View File

@ -33,13 +33,13 @@ import org.openhab.core.thing.ThingUID;
*/ */
@NonNullByDefault @NonNullByDefault
public class RFXComTestHelper { public class RFXComTestHelper {
static final public ThingUID bridgeUID = new ThingUID("rfxcom", "tcpbridge", "rfxtrx0"); public static final ThingUID bridgeUID = new ThingUID("rfxcom", "tcpbridge", "rfxtrx0");
static final public ThingUID thingUID = new ThingUID("rfxcom", bridgeUID, "mocked"); public static final ThingUID thingUID = new ThingUID("rfxcom", bridgeUID, "mocked");
static final public ThingTypeUID thingTypeUID = new ThingTypeUID("rfxcom", "raw"); public static final ThingTypeUID thingTypeUID = new ThingTypeUID("rfxcom", "raw");
static final public ChannelUID commandChannelUID = new ChannelUID(thingUID, RFXComBindingConstants.CHANNEL_COMMAND); public static final ChannelUID commandChannelUID = new ChannelUID(thingUID, RFXComBindingConstants.CHANNEL_COMMAND);
static public void basicBoundaryCheck(PacketType packetType, RFXComMessage message) throws RFXComException { public static void basicBoundaryCheck(PacketType packetType, RFXComMessage message) throws RFXComException {
// This is a place where its easy to make mistakes in coding, and can result in errors, normally // This is a place where its easy to make mistakes in coding, and can result in errors, normally
// array bounds errors // array bounds errors
byte[] binaryMessage = message.decodeMessage(); byte[] binaryMessage = message.decodeMessage();
@ -47,7 +47,7 @@ public class RFXComTestHelper {
assertEquals(packetType.toByte(), binaryMessage[1], "Wrong packet type"); assertEquals(packetType.toByte(), binaryMessage[1], "Wrong packet type");
} }
static public int getActualIntValue(RFXComDeviceMessage msg, RFXComDeviceConfiguration config, String channelId) public static int getActualIntValue(RFXComDeviceMessage msg, RFXComDeviceConfiguration config, String channelId)
throws RFXComException { throws RFXComException {
return ((DecimalType) msg.convertToState(channelId, config, new MockDeviceState())).intValue(); return ((DecimalType) msg.convertToState(channelId, config, new MockDeviceState())).intValue();
} }

View File

@ -46,9 +46,9 @@ import org.openhab.core.util.HexUtils;
*/ */
@NonNullByDefault @NonNullByDefault
public class RFXComLighting4MessageTest { public class RFXComLighting4MessageTest {
static public final ChannelUID contactChannelUID = new ChannelUID(thingUID, CHANNEL_CONTACT); public static final ChannelUID contactChannelUID = new ChannelUID(thingUID, CHANNEL_CONTACT);
static public void checkDiscoveryResult(RFXComDeviceMessage<RFXComLighting4Message.SubType> msg, String deviceId, public static void checkDiscoveryResult(RFXComDeviceMessage<RFXComLighting4Message.SubType> msg, String deviceId,
@Nullable Integer pulse, String subType) throws RFXComException { @Nullable Integer pulse, String subType) throws RFXComException {
String thingUID = "homeduino:rfxcom:fssfsd:thing"; String thingUID = "homeduino:rfxcom:fssfsd:thing";
DiscoveryResultBuilder builder = DiscoveryResultBuilder.create(new ThingUID(thingUID)); DiscoveryResultBuilder builder = DiscoveryResultBuilder.create(new ThingUID(thingUID));

View File

@ -142,6 +142,7 @@ public class RioSystemConfig {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -242,12 +242,12 @@ public class SamsungTvHandler extends BaseThingHandler implements RegistryListen
boolean isOnline = false; boolean isOnline = false;
for (Device<?, ?, ?> device : upnpService.getRegistry().getDevices()) { for (Device<?, ?, ?> device : upnpService.getRegistry().getDevices()) {
if (createService((RemoteDevice) device) == true) { if (createService((RemoteDevice) device)) {
isOnline = true; isOnline = true;
} }
} }
if (isOnline == true) { if (isOnline) {
logger.debug("Device was online"); logger.debug("Device was online");
putOnline(); putOnline();
} else { } else {

View File

@ -158,6 +158,7 @@ public class SatelMessage {
return String.format("Message: command = %02X, payload = %s", this.command, getPayloadAsHex()); return String.format("Message: command = %02X, payload = %s", this.command, getPayloadAsHex());
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -188,8 +188,8 @@ public class ShellyBindingConstants {
public static final String CHANNEL_ESENSOR_TEMP5 = CHANNEL_SENSOR_TEMP + "5"; public static final String CHANNEL_ESENSOR_TEMP5 = CHANNEL_SENSOR_TEMP + "5";
public static final String CHANNEL_ESENSOR_HUMIDITY = CHANNEL_SENSOR_HUM; public static final String CHANNEL_ESENSOR_HUMIDITY = CHANNEL_SENSOR_HUM;
public static final String CHANNEL_ESENSOR_VOLTAGE = CHANNEL_SENSOR_VOLTAGE; public static final String CHANNEL_ESENSOR_VOLTAGE = CHANNEL_SENSOR_VOLTAGE;
public static final String CHANNEL_ESENSOR_DIGITALINPUT = "digitalInput";; public static final String CHANNEL_ESENSOR_DIGITALINPUT = "digitalInput";
public static final String CHANNEL_ESENSOR_ANALOGINPUT = "analogInput";; public static final String CHANNEL_ESENSOR_ANALOGINPUT = "analogInput";
public static final String CHANNEL_ESENSOR_INPUT = "input"; public static final String CHANNEL_ESENSOR_INPUT = "input";
public static final String CHANNEL_ESENSOR_INPUT1 = CHANNEL_ESENSOR_INPUT + "1"; public static final String CHANNEL_ESENSOR_INPUT1 = CHANNEL_ESENSOR_INPUT + "1";

View File

@ -74,6 +74,7 @@ public class MeterValue<Q extends Quantity<Q>> {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -66,6 +66,7 @@ public class NegateBitModel {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -939,7 +939,7 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
boolean hasitems = "1".equals(entry.value); boolean hasitems = "1".equals(entry.value);
if (f != null) { if (f != null) {
// Except for some favorites (e.g. Spotify) use hasitems:1 and type:playlist // Except for some favorites (e.g. Spotify) use hasitems:1 and type:playlist
if (hasitems && isTypePlaylist == false) { if (hasitems && !isTypePlaylist) {
// Skip subfolders // Skip subfolders
favorites.remove(f); favorites.remove(f);
f = null; f = null;

View File

@ -53,5 +53,5 @@ public class TACmiBindingConstants {
"schema-state-ro"); "schema-state-ro");
// Channel specific configuration items // Channel specific configuration items
public final static String CHANNEL_CONFIG_OUTPUT = "output"; public static final String CHANNEL_CONFIG_OUTPUT = "output";
} }

View File

@ -86,6 +86,7 @@ public final class DigitalMessage extends Message {
* @param portNumber - the portNumber in Range 1-32 * @param portNumber - the portNumber in Range 1-32
* @return * @return
*/ */
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean hasPortnumber(int portNumber) { public boolean hasPortnumber(int portNumber) {
if (podNumber == 0 && portNumber <= 16) { if (podNumber == 0 && portNumber <= 16) {

View File

@ -128,7 +128,7 @@ public class StationHandler extends BaseThingHandler {
*/ */
public void updateData(LittleStation station) { public void updateData(LittleStation station) {
logger.debug("Update Tankerkoenig data '{}'", getThing().getUID()); logger.debug("Update Tankerkoenig data '{}'", getThing().getUID());
if (station.isOpen() == true) { if (station.isOpen()) {
logger.debug("Checked Station is open! '{}'", getThing().getUID()); logger.debug("Checked Station is open! '{}'", getThing().getUID());
updateState(CHANNEL_STATION_OPEN, OpenClosedType.OPEN); updateState(CHANNEL_STATION_OPEN, OpenClosedType.OPEN);
if (station.getDiesel() != null) { if (station.getDiesel() != null) {

View File

@ -34,7 +34,7 @@ import com.google.gson.JsonParser;
@NonNullByDefault @NonNullByDefault
public class TouchWandUnitFromJson { public class TouchWandUnitFromJson {
private final static Logger logger = LoggerFactory.getLogger(TouchWandUnitFromJson.class); private static final Logger logger = LoggerFactory.getLogger(TouchWandUnitFromJson.class);
public TouchWandUnitFromJson() { public TouchWandUnitFromJson() {
} }

View File

@ -91,11 +91,7 @@ public class VelbusRelayWithInputHandler extends VelbusRelayHandler {
private boolean isTriggerChannel(byte address, byte channel) { private boolean isTriggerChannel(byte address, byte channel) {
VelbusChannelIdentifier velbusChannelIdentifier = new VelbusChannelIdentifier(address, channel); VelbusChannelIdentifier velbusChannelIdentifier = new VelbusChannelIdentifier(address, channel);
if (getModuleAddress().getChannelNumber(velbusChannelIdentifier) == 6) { return getModuleAddress().getChannelNumber(velbusChannelIdentifier) == 6;
return true;
} else {
return false;
}
} }
@Override @Override

View File

@ -327,10 +327,8 @@ public class VentaThingHandler extends BaseThingHandler {
} }
private boolean messageIsEmpty(DeviceInfoMessage message) { private boolean messageIsEmpty(DeviceInfoMessage message) {
if (message.getCurrentActions() == null && message.getInfo() == null && message.getMeasurements() == null) { return (message.getCurrentActions() == null && message.getInfo() == null
return true; && message.getMeasurements() == null);
}
return false;
} }
/** /**

View File

@ -40,6 +40,7 @@ public class VerisureAlarmsDTO extends VerisureBaseThingDTO {
return super.hashCode(); return super.hashCode();
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -216,6 +216,7 @@ public abstract class VerisureBaseThingDTO implements VerisureThingDTO {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {
@ -343,6 +344,7 @@ public abstract class VerisureBaseThingDTO implements VerisureThingDTO {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -39,6 +39,7 @@ public class VerisureBroadbandConnectionsDTO extends VerisureBaseThingDTO {
return super.hashCode(); return super.hashCode();
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -126,6 +126,7 @@ public class VerisureDoorWindowsDTO extends VerisureBaseThingDTO {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -37,6 +37,7 @@ public class VerisureGatewayDTO extends VerisureBaseThingDTO {
return super.hashCode(); return super.hashCode();
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -44,6 +44,7 @@ public class VerisureInstallationsDTO {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {
@ -92,6 +93,7 @@ public class VerisureInstallationsDTO {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -67,6 +67,7 @@ public class VerisureMiceDetectionDTO extends VerisureBaseThingDTO {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -148,6 +148,7 @@ public class VerisureSmartLockDTO {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -39,6 +39,7 @@ public class VerisureSmartPlugsDTO extends VerisureBaseThingDTO {
return super.hashCode(); return super.hashCode();
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -39,6 +39,7 @@ public class VerisureUserPresencesDTO extends VerisureBaseThingDTO {
return super.hashCode(); return super.hashCode();
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -131,7 +131,7 @@ public class WemoUtil {
} }
public static String createBinaryStateContent(boolean binaryState) { public static String createBinaryStateContent(boolean binaryState) {
String binary = binaryState == true ? "1" : "0"; String binary = binaryState ? "1" : "0";
String content = "<?xml version=\"1.0\"?>" String content = "<?xml version=\"1.0\"?>"
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+ "<s:Body>" + "<u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<BinaryState>" + "<s:Body>" + "<u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<BinaryState>"

View File

@ -141,7 +141,7 @@ public class ZmBridgeHandler extends BaseBridgeHandler {
defaultImageRefreshInterval = config.defaultImageRefreshInterval; defaultImageRefreshInterval = config.defaultImageRefreshInterval;
backgroundDiscoveryEnabled = config.discoveryEnabled; backgroundDiscoveryEnabled = config.discoveryEnabled;
logger.debug("Bridge: Background discovery is {}", backgroundDiscoveryEnabled == true ? "ENABLED" : "DISABLED"); logger.debug("Bridge: Background discovery is {}", backgroundDiscoveryEnabled ? "ENABLED" : "DISABLED");
host = config.host; host = config.host;
useSSL = config.useSSL.booleanValue(); useSSL = config.useSSL.booleanValue();

View File

@ -60,9 +60,9 @@ import io.github.hapjava.server.impl.HomekitRoot;
@NonNullByDefault @NonNullByDefault
public class HomekitChangeListener implements ItemRegistryChangeListener { public class HomekitChangeListener implements ItemRegistryChangeListener {
private final Logger logger = LoggerFactory.getLogger(HomekitChangeListener.class); private final Logger logger = LoggerFactory.getLogger(HomekitChangeListener.class);
private final static String REVISION_CONFIG = "revision"; private static final String REVISION_CONFIG = "revision";
private final static String ACCESSORY_COUNT = "accessory_count"; private static final String ACCESSORY_COUNT = "accessory_count";
private final static String KNOWN_ACCESSORIES = "known_accessories"; private static final String KNOWN_ACCESSORIES = "known_accessories";
private final ItemRegistry itemRegistry; private final ItemRegistry itemRegistry;
private final HomekitAccessoryRegistry accessoryRegistry = new HomekitAccessoryRegistry(); private final HomekitAccessoryRegistry accessoryRegistry = new HomekitAccessoryRegistry();
private final MetadataRegistry metadataRegistry; private final MetadataRegistry metadataRegistry;
@ -291,7 +291,6 @@ public class HomekitChangeListener implements ItemRegistryChangeListener {
try { try {
boolean changed = false; boolean changed = false;
boolean removed = false;
for (final String name : pendingUpdates) { for (final String name : pendingUpdates) {
String oldValue = knownAccessories.get(name); String oldValue = knownAccessories.get(name);
accessoryRegistry.remove(name); accessoryRegistry.remove(name);

View File

@ -66,6 +66,7 @@ public class HomekitSettings {
return result; return result;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -50,18 +50,18 @@ public class HomekitTaggedItem {
private final Logger logger = LoggerFactory.getLogger(HomekitTaggedItem.class); private final Logger logger = LoggerFactory.getLogger(HomekitTaggedItem.class);
/** configuration keywords at items level **/ /** configuration keywords at items level **/
public final static String DELAY = "commandDelay"; public static final String DELAY = "commandDelay";
public final static String DIMMER_MODE = "dimmerMode"; public static final String DIMMER_MODE = "dimmerMode";
public static final String BATTERY_LOW_THRESHOLD = "lowThreshold"; public static final String BATTERY_LOW_THRESHOLD = "lowThreshold";
public final static String INSTANCE = "instance"; public static final String INSTANCE = "instance";
public final static String INVERTED = "inverted"; public static final String INVERTED = "inverted";
public final static String MAX_VALUE = "maxValue"; public static final String MAX_VALUE = "maxValue";
public final static String MIN_VALUE = "minValue"; public static final String MIN_VALUE = "minValue";
public final static String PRIMARY_SERVICE = "primary"; public static final String PRIMARY_SERVICE = "primary";
public final static String STEP = "step"; public static final String STEP = "step";
public final static String UNIT = "unit"; public static final String UNIT = "unit";
public final static String EMULATE_STOP_STATE = "stop"; public static final String EMULATE_STOP_STATE = "stop";
public final static String EMULATE_STOP_SAME_DIRECTION = "stopSameDirection"; public static final String EMULATE_STOP_SAME_DIRECTION = "stopSameDirection";
private static final Map<Integer, String> CREATED_ACCESSORY_IDS = new ConcurrentHashMap<>(); private static final Map<Integer, String> CREATED_ACCESSORY_IDS = new ConcurrentHashMap<>();

View File

@ -63,10 +63,10 @@ import io.github.hapjava.characteristics.impl.common.NameCharacteristic;
@NonNullByDefault @NonNullByDefault
public class HomekitAccessoryFactory { public class HomekitAccessoryFactory {
private static final Logger logger = LoggerFactory.getLogger(HomekitAccessoryFactory.class); private static final Logger logger = LoggerFactory.getLogger(HomekitAccessoryFactory.class);
public final static String METADATA_KEY = "homekit"; // prefix for HomeKit meta information in items.xml public static final String METADATA_KEY = "homekit"; // prefix for HomeKit meta information in items.xml
/** List of mandatory attributes for each accessory type. **/ /** List of mandatory attributes for each accessory type. **/
private final static Map<HomekitAccessoryType, HomekitCharacteristicType[]> MANDATORY_CHARACTERISTICS = new HashMap<HomekitAccessoryType, HomekitCharacteristicType[]>() { private static final Map<HomekitAccessoryType, HomekitCharacteristicType[]> MANDATORY_CHARACTERISTICS = new HashMap<HomekitAccessoryType, HomekitCharacteristicType[]>() {
{ {
put(ACCESSORY_GROUP, new HomekitCharacteristicType[] {}); put(ACCESSORY_GROUP, new HomekitCharacteristicType[] {});
put(LEAK_SENSOR, new HomekitCharacteristicType[] { LEAK_DETECTED_STATE }); put(LEAK_SENSOR, new HomekitCharacteristicType[] { LEAK_DETECTED_STATE });
@ -112,7 +112,7 @@ public class HomekitAccessoryFactory {
}; };
/** List of service implementation for each accessory type. **/ /** List of service implementation for each accessory type. **/
private final static Map<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>> SERVICE_IMPL_MAP = new HashMap<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>>() { private static final Map<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>> SERVICE_IMPL_MAP = new HashMap<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>>() {
{ {
put(ACCESSORY_GROUP, HomekitAccessoryGroupImpl.class); put(ACCESSORY_GROUP, HomekitAccessoryGroupImpl.class);
put(LEAK_SENSOR, HomekitLeakSensorImpl.class); put(LEAK_SENSOR, HomekitLeakSensorImpl.class);
@ -436,8 +436,9 @@ public class HomekitAccessoryFactory {
MetadataRegistry metadataRegistry, HomekitAccessoryUpdater updater, HomekitSettings settings, MetadataRegistry metadataRegistry, HomekitAccessoryUpdater updater, HomekitSettings settings,
Set<HomekitTaggedItem> ancestorServices) throws HomekitException { Set<HomekitTaggedItem> ancestorServices) throws HomekitException {
final var item = taggedItem.getItem(); final var item = taggedItem.getItem();
if (!(item instanceof GroupItem)) if (!(item instanceof GroupItem)) {
return; return;
}
for (var groupMember : ((GroupItem) item).getMembers().stream() for (var groupMember : ((GroupItem) item).getMembers().stream()
.sorted((lhs, rhs) -> lhs.getName().compareTo(rhs.getName())).collect(Collectors.toList())) { .sorted((lhs, rhs) -> lhs.getName().compareTo(rhs.getName())).collect(Collectors.toList())) {
@ -446,8 +447,9 @@ public class HomekitAccessoryFactory {
.collect(Collectors.toList()); .collect(Collectors.toList());
logger.trace("accessory types for {} are {}", groupMember.getName(), accessoryTypes); logger.trace("accessory types for {} are {}", groupMember.getName(), accessoryTypes);
if (accessoryTypes.isEmpty()) if (accessoryTypes.isEmpty()) {
continue; continue;
}
if (accessoryTypes.size() > 1) { if (accessoryTypes.size() > 1) {
logger.warn("Item {} is a HomeKit sub-accessory, but multiple accessory types are not allowed.", logger.warn("Item {} is a HomeKit sub-accessory, but multiple accessory types are not allowed.",

View File

@ -162,7 +162,7 @@ public class HomekitCharacteristicFactory {
private static final Logger logger = LoggerFactory.getLogger(HomekitCharacteristicFactory.class); private static final Logger logger = LoggerFactory.getLogger(HomekitCharacteristicFactory.class);
// List of optional characteristics and corresponding method to create them. // List of optional characteristics and corresponding method to create them.
private final static Map<HomekitCharacteristicType, BiFunction<HomekitTaggedItem, HomekitAccessoryUpdater, Characteristic>> optional = new HashMap<HomekitCharacteristicType, BiFunction<HomekitTaggedItem, HomekitAccessoryUpdater, Characteristic>>() { private static final Map<HomekitCharacteristicType, BiFunction<HomekitTaggedItem, HomekitAccessoryUpdater, Characteristic>> optional = new HashMap<HomekitCharacteristicType, BiFunction<HomekitTaggedItem, HomekitAccessoryUpdater, Characteristic>>() {
{ {
put(NAME, HomekitCharacteristicFactory::createNameCharacteristic); put(NAME, HomekitCharacteristicFactory::createNameCharacteristic);
put(BATTERY_LOW_STATUS, HomekitCharacteristicFactory::createStatusLowBatteryCharacteristic); put(BATTERY_LOW_STATUS, HomekitCharacteristicFactory::createStatusLowBatteryCharacteristic);

View File

@ -32,7 +32,7 @@ import io.github.hapjava.services.impl.HumiditySensorService;
* @author Andy Lintner - Initial contribution * @author Andy Lintner - Initial contribution
*/ */
public class HomekitHumiditySensorImpl extends AbstractHomekitAccessoryImpl implements HumiditySensorAccessory { public class HomekitHumiditySensorImpl extends AbstractHomekitAccessoryImpl implements HumiditySensorAccessory {
private final static String CONFIG_MULTIPLICATOR = "homekitMultiplicator"; private static final String CONFIG_MULTIPLICATOR = "homekitMultiplicator";
public HomekitHumiditySensorImpl(HomekitTaggedItem taggedItem, List<HomekitTaggedItem> mandatoryCharacteristics, public HomekitHumiditySensorImpl(HomekitTaggedItem taggedItem, List<HomekitTaggedItem> mandatoryCharacteristics,
HomekitAccessoryUpdater updater, HomekitSettings settings) { HomekitAccessoryUpdater updater, HomekitSettings settings) {

View File

@ -106,7 +106,7 @@ public class DynamoDBPersistenceService implements QueryablePersistenceService {
private ItemRegistry itemRegistry; private ItemRegistry itemRegistry;
private @Nullable DynamoDbEnhancedAsyncClient client; private @Nullable DynamoDbEnhancedAsyncClient client;
private @Nullable DynamoDbAsyncClient lowLevelClient; private @Nullable DynamoDbAsyncClient lowLevelClient;
private final static Logger logger = LoggerFactory.getLogger(DynamoDBPersistenceService.class); private static final Logger logger = LoggerFactory.getLogger(DynamoDBPersistenceService.class);
private boolean isProperlyConfigured; private boolean isProperlyConfigured;
private @Nullable DynamoDBConfig dbConfig; private @Nullable DynamoDBConfig dbConfig;
private @Nullable DynamoDBTableNameResolver tableNameResolver; private @Nullable DynamoDBTableNameResolver tableNameResolver;

View File

@ -93,7 +93,7 @@ public class BaseIntegrationTest extends JavaTest {
protected static final Unit<Dimensionless> DIMENSIONLESS_ITEM_UNIT = Units.ONE; protected static final Unit<Dimensionless> DIMENSIONLESS_ITEM_UNIT = Units.ONE;
private static @Nullable URI endpointOverride; private static @Nullable URI endpointOverride;
protected static UnitProvider UNIT_PROVIDER; protected static final UnitProvider UNIT_PROVIDER;
static { static {
ComponentContext context = Mockito.mock(ComponentContext.class); ComponentContext context = Mockito.mock(ComponentContext.class);
BundleContext bundleContext = Mockito.mock(BundleContext.class); BundleContext bundleContext = Mockito.mock(BundleContext.class);
@ -192,7 +192,7 @@ public class BaseIntegrationTest extends JavaTest {
* @param tablePrefix * @param tablePrefix
* @return new persistence service * @return new persistence service
*/ */
protected synchronized static DynamoDBPersistenceService newService(@Nullable Boolean legacy, boolean cleanLocal, protected static synchronized DynamoDBPersistenceService newService(@Nullable Boolean legacy, boolean cleanLocal,
@Nullable URI overrideLocalURI, @Nullable String table, @Nullable String tablePrefix) { @Nullable URI overrideLocalURI, @Nullable String table, @Nullable String tablePrefix) {
final DynamoDBPersistenceService service; final DynamoDBPersistenceService service;
Map<String, Object> config = getConfig(legacy, table, tablePrefix); Map<String, Object> config = getConfig(legacy, table, tablePrefix);

View File

@ -73,11 +73,12 @@ public class Influx2FilterCriteriaQueryCreatorImpl implements FilterCriteriaQuer
flux = flux.filter(tag(TAG_ITEM_NAME).equal(itemName)); flux = flux.filter(tag(TAG_ITEM_NAME).equal(itemName));
} }
if (needsToUseItemTagName) if (needsToUseItemTagName) {
flux = flux.keep(new String[] { FIELD_MEASUREMENT_NAME, COLUMN_TIME_NAME_V2, COLUMN_VALUE_NAME_V2, flux = flux.keep(new String[] { FIELD_MEASUREMENT_NAME, COLUMN_TIME_NAME_V2, COLUMN_VALUE_NAME_V2,
TAG_ITEM_NAME }); TAG_ITEM_NAME });
else } else {
flux = flux.keep(new String[] { FIELD_MEASUREMENT_NAME, COLUMN_TIME_NAME_V2, COLUMN_VALUE_NAME_V2 }); flux = flux.keep(new String[] { FIELD_MEASUREMENT_NAME, COLUMN_TIME_NAME_V2, COLUMN_VALUE_NAME_V2 });
}
} }
if (criteria.getState() != null && criteria.getOperator() != null) { if (criteria.getState() != null && criteria.getOperator() != null) {

View File

@ -74,6 +74,7 @@ public class Range {
this.maxInclusive = maxInclusive; this.maxInclusive = maxInclusive;
} }
@SuppressWarnings("PMD.SimplifyBooleanReturns")
public boolean contains(final BigDecimal value) { public boolean contains(final BigDecimal value) {
final boolean minMatch; final boolean minMatch;
if (min == null) { if (min == null) {