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;
}
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {

View File

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

View File

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

View File

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

View File

@ -113,11 +113,7 @@ public class DigiplexResponseResolver {
}
private static boolean toBoolean(char value) {
if (value == 'O') {
return false;
} else {
return true;
}
return value != 'O';
}
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.
// I did never encounter 255 on my system though (EVO192).
// 15 is returned instead, which (I believe) has the same meaning.
if (this.areaNo == 15 || this.areaNo == 255) {
return true;
}
return false;
return (this.areaNo == 15 || this.areaNo == 255);
}
}

View File

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

View File

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

View File

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

View File

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

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,
PANEL_ZONE_FAULT, PANEL_ZONE_TAMPER, PANEL_ZONE_LOW_BATTERY, PANEL_TIME_LOSS };
String channel;
ChannelUID channelUID = null;
int bitCount = 8;

View File

@ -40,12 +40,8 @@ public class A5_11_03 extends _4BSMessage {
int state = (db1 >> 4) & 0x03;
if (state != 0) {
// TODO: display error state on thing
return true;
} else {
return false;
}
return state != 0;
}
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 });
}
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) {
return new SAMessage(SAMessageType.SA_RD_MAILBOX_STATUS,

View File

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

View File

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

View File

@ -38,7 +38,7 @@ public class FroniusHttpUtil {
* @return the response body
* @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;
try {
while (true) {

View File

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

View File

@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
public class Device {
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 String id;
public String deviceType;

View File

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

View File

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

View File

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

View File

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

View File

@ -60,7 +60,7 @@ import com.google.gson.JsonSyntaxException;
@NonNullByDefault
public class GreeAirDevice {
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 final InetAddress ipAddress;
private int port = 0;
@ -80,7 +80,6 @@ public class GreeAirDevice {
}
public void getDeviceStatus(DatagramSocket clientSocket) throws GreeException {
if (!isBound) {
throw new GreeException("Device not bound");
}

View File

@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault
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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault
public class MagentaTVControl {
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 MagentaTVHttp http = new MagentaTVHttp();

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@
*/
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.openhab.binding.modbus.sunspec.internal.SunSpecConstants;
@ -52,10 +52,10 @@ public class CommonModelParser extends AbstractBaseParser implements SunspecPars
}
// parse manufacturer, model and version
block.manufacturer = ModbusBitUtilities.extractStringFromRegisters(raw, 2, 32, Charset.forName("UTF-8"));
block.model = ModbusBitUtilities.extractStringFromRegisters(raw, 18, 32, Charset.forName("UTF-8"));
block.version = ModbusBitUtilities.extractStringFromRegisters(raw, 42, 16, Charset.forName("UTF-8"));
block.serialNumber = ModbusBitUtilities.extractStringFromRegisters(raw, 50, 32, Charset.forName("UTF-8"));
block.manufacturer = ModbusBitUtilities.extractStringFromRegisters(raw, 2, 32, StandardCharsets.UTF_8);
block.model = ModbusBitUtilities.extractStringFromRegisters(raw, 18, 32, StandardCharsets.UTF_8);
block.version = ModbusBitUtilities.extractStringFromRegisters(raw, 42, 16, StandardCharsets.UTF_8);
block.serialNumber = ModbusBitUtilities.extractStringFromRegisters(raw, 50, 32, StandardCharsets.UTF_8);
block.deviceAddress = extractUInt16(raw, 66, 1);

View File

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

View File

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

View File

@ -299,9 +299,9 @@ public class NikobusPushButtonHandler extends NikobusBaseThingHandler {
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 {

View File

@ -294,8 +294,8 @@ public class NikobusRollershutterModuleHandler extends NikobusModuleHandler {
final int up;
final int down;
final static DirectionConfiguration NORMAL = new DirectionConfiguration(1, 2);
final static DirectionConfiguration REVERSED = new DirectionConfiguration(2, 1);
static final DirectionConfiguration NORMAL = new DirectionConfiguration(1, 2);
static final DirectionConfiguration REVERSED = new DirectionConfiguration(2, 1);
private DirectionConfiguration(int up, int down) {
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_MENU9 = "netmenu#item9";
public final static String CHANNEL_AUDIO_IN_INFO = "info#audioIn";
public final static String CHANNEL_AUDIO_OUT_INFO = "info#audioOut";
public final static String CHANNEL_VIDEO_IN_INFO = "info#videoIn";
public final static String CHANNEL_VIDEO_OUT_INFO = "info#videoOut";
public static final String CHANNEL_AUDIO_IN_INFO = "info#audioIn";
public static final String CHANNEL_AUDIO_OUT_INFO = "info#audioOut";
public static final String CHANNEL_VIDEO_IN_INFO = "info#videoIn";
public static final String CHANNEL_VIDEO_OUT_INFO = "info#videoOut";
// Used for Discovery service
public static final String MANUFACTURER = "ONKYO";

View File

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

View File

@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
public class ParadoxUtil {
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) {
int result = 0;

View File

@ -41,7 +41,7 @@ public class TestGetBytes {
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,
(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;
}
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {

View File

@ -37,6 +37,7 @@ public class MACAddress {
return result;
}
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override
public boolean equals(@Nullable Object 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 */
@SuppressWarnings("PMD.SimplifyBooleanReturns")
private boolean isSpecialValue(Double dd) {
if ((Math.abs(dd - 888.8) < 0.1) || (Math.abs(dd - (-888.8)) < 0.1)) {
/* value out of range */

View File

@ -33,13 +33,13 @@ import org.openhab.core.thing.ThingUID;
*/
@NonNullByDefault
public class RFXComTestHelper {
static final public ThingUID bridgeUID = new ThingUID("rfxcom", "tcpbridge", "rfxtrx0");
static final public ThingUID thingUID = new ThingUID("rfxcom", bridgeUID, "mocked");
static final public ThingTypeUID thingTypeUID = new ThingTypeUID("rfxcom", "raw");
public static final ThingUID bridgeUID = new ThingUID("rfxcom", "tcpbridge", "rfxtrx0");
public static final ThingUID thingUID = new ThingUID("rfxcom", bridgeUID, "mocked");
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
// array bounds errors
byte[] binaryMessage = message.decodeMessage();
@ -47,7 +47,7 @@ public class RFXComTestHelper {
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 {
return ((DecimalType) msg.convertToState(channelId, config, new MockDeviceState())).intValue();
}

View File

@ -46,9 +46,9 @@ import org.openhab.core.util.HexUtils;
*/
@NonNullByDefault
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 {
String thingUID = "homeduino:rfxcom:fssfsd:thing";
DiscoveryResultBuilder builder = DiscoveryResultBuilder.create(new ThingUID(thingUID));

View File

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

View File

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

View File

@ -158,6 +158,7 @@ public class SatelMessage {
return String.format("Message: command = %02X, payload = %s", this.command, getPayloadAsHex());
}
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override
public boolean equals(@Nullable Object 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_HUMIDITY = CHANNEL_SENSOR_HUM;
public static final String CHANNEL_ESENSOR_VOLTAGE = CHANNEL_SENSOR_VOLTAGE;
public static final String CHANNEL_ESENSOR_DIGITALINPUT = "digitalInput";;
public static final String CHANNEL_ESENSOR_ANALOGINPUT = "analogInput";;
public static final String CHANNEL_ESENSOR_DIGITALINPUT = "digitalInput";
public static final String CHANNEL_ESENSOR_ANALOGINPUT = "analogInput";
public static final String CHANNEL_ESENSOR_INPUT = "input";
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;
}
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {

View File

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

View File

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

View File

@ -53,5 +53,5 @@ public class TACmiBindingConstants {
"schema-state-ro");
// 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
* @return
*/
@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override
public boolean hasPortnumber(int portNumber) {
if (podNumber == 0 && portNumber <= 16) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -131,7 +131,7 @@ public class WemoUtil {
}
public static String createBinaryStateContent(boolean binaryState) {
String binary = binaryState == true ? "1" : "0";
String binary = binaryState ? "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: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;
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;
useSSL = config.useSSL.booleanValue();

View File

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

View File

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

View File

@ -50,18 +50,18 @@ public class HomekitTaggedItem {
private final Logger logger = LoggerFactory.getLogger(HomekitTaggedItem.class);
/** configuration keywords at items level **/
public final static String DELAY = "commandDelay";
public final static String DIMMER_MODE = "dimmerMode";
public static final String DELAY = "commandDelay";
public static final String DIMMER_MODE = "dimmerMode";
public static final String BATTERY_LOW_THRESHOLD = "lowThreshold";
public final static String INSTANCE = "instance";
public final static String INVERTED = "inverted";
public final static String MAX_VALUE = "maxValue";
public final static String MIN_VALUE = "minValue";
public final static String PRIMARY_SERVICE = "primary";
public final static String STEP = "step";
public final static String UNIT = "unit";
public final static String EMULATE_STOP_STATE = "stop";
public final static String EMULATE_STOP_SAME_DIRECTION = "stopSameDirection";
public static final String INSTANCE = "instance";
public static final String INVERTED = "inverted";
public static final String MAX_VALUE = "maxValue";
public static final String MIN_VALUE = "minValue";
public static final String PRIMARY_SERVICE = "primary";
public static final String STEP = "step";
public static final String UNIT = "unit";
public static final String EMULATE_STOP_STATE = "stop";
public static final String EMULATE_STOP_SAME_DIRECTION = "stopSameDirection";
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
public class HomekitAccessoryFactory {
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. **/
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(LEAK_SENSOR, new HomekitCharacteristicType[] { LEAK_DETECTED_STATE });
@ -112,7 +112,7 @@ public class HomekitAccessoryFactory {
};
/** 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(LEAK_SENSOR, HomekitLeakSensorImpl.class);
@ -436,8 +436,9 @@ public class HomekitAccessoryFactory {
MetadataRegistry metadataRegistry, HomekitAccessoryUpdater updater, HomekitSettings settings,
Set<HomekitTaggedItem> ancestorServices) throws HomekitException {
final var item = taggedItem.getItem();
if (!(item instanceof GroupItem))
if (!(item instanceof GroupItem)) {
return;
}
for (var groupMember : ((GroupItem) item).getMembers().stream()
.sorted((lhs, rhs) -> lhs.getName().compareTo(rhs.getName())).collect(Collectors.toList())) {
@ -446,8 +447,9 @@ public class HomekitAccessoryFactory {
.collect(Collectors.toList());
logger.trace("accessory types for {} are {}", groupMember.getName(), accessoryTypes);
if (accessoryTypes.isEmpty())
if (accessoryTypes.isEmpty()) {
continue;
}
if (accessoryTypes.size() > 1) {
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);
// 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(BATTERY_LOW_STATUS, HomekitCharacteristicFactory::createStatusLowBatteryCharacteristic);

View File

@ -32,7 +32,7 @@ import io.github.hapjava.services.impl.HumiditySensorService;
* @author Andy Lintner - Initial contribution
*/
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,
HomekitAccessoryUpdater updater, HomekitSettings settings) {

View File

@ -106,7 +106,7 @@ public class DynamoDBPersistenceService implements QueryablePersistenceService {
private ItemRegistry itemRegistry;
private @Nullable DynamoDbEnhancedAsyncClient client;
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 @Nullable DynamoDBConfig dbConfig;
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;
private static @Nullable URI endpointOverride;
protected static UnitProvider UNIT_PROVIDER;
protected static final UnitProvider UNIT_PROVIDER;
static {
ComponentContext context = Mockito.mock(ComponentContext.class);
BundleContext bundleContext = Mockito.mock(BundleContext.class);
@ -192,7 +192,7 @@ public class BaseIntegrationTest extends JavaTest {
* @param tablePrefix
* @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) {
final DynamoDBPersistenceService service;
Map<String, Object> config = getConfig(legacy, table, tablePrefix);

View File

@ -73,12 +73,13 @@ public class Influx2FilterCriteriaQueryCreatorImpl implements FilterCriteriaQuer
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,
TAG_ITEM_NAME });
else
} else {
flux = flux.keep(new String[] { FIELD_MEASUREMENT_NAME, COLUMN_TIME_NAME_V2, COLUMN_VALUE_NAME_V2 });
}
}
if (criteria.getState() != null && criteria.getOperator() != null) {
Restrictions restrictions = Restrictions.and(Restrictions.field().equal(FIELD_VALUE_NAME),

View File

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