Java 17 features (A-G) (#15516)
- add missing @override - Java style array syntax - remove redundant modifiers - always move String constants to left side in comparisons - simplify lambda expressions and return statements - use replace instead of replaceAll w/o regex - instanceof matching and multiline strings Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -41,8 +41,8 @@ public class Ipx800Actions implements ThingActions {
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof Ipx800v3Handler) {
|
||||
this.handler = (Ipx800v3Handler) handler;
|
||||
if (handler instanceof Ipx800v3Handler ipx800v3Handler) {
|
||||
this.handler = ipx800v3Handler;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -327,11 +326,11 @@ public class Ipx800v3Handler extends BaseThingHandler implements Ipx800EventList
|
||||
if (channel == null || groupId == null) {
|
||||
return;
|
||||
}
|
||||
if (command instanceof OnOffType && isValidPortId(channelUID)
|
||||
if (command instanceof OnOffType onOffCommand && isValidPortId(channelUID)
|
||||
&& PortDefinition.fromGroupId(groupId) == PortDefinition.RELAY) {
|
||||
RelayOutputConfiguration config = channel.getConfiguration().as(RelayOutputConfiguration.class);
|
||||
String id = channelUID.getIdWithoutGroup();
|
||||
parser.ifPresent(p -> p.setOutput(id, (OnOffType) command == OnOffType.ON ? 1 : 0, config.pulse));
|
||||
parser.ifPresent(p -> p.setOutput(id, onOffCommand == OnOffType.ON ? 1 : 0, config.pulse));
|
||||
return;
|
||||
}
|
||||
logger.debug("Can not handle command '{}' on channel '{}'", command, channelUID);
|
||||
@@ -351,6 +350,6 @@ public class Ipx800v3Handler extends BaseThingHandler implements Ipx800EventList
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singletonList(Ipx800Actions.class);
|
||||
return List.of(Ipx800Actions.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class M2MMessageParser {
|
||||
decodeDataLine(portDefinition, data);
|
||||
} else if (VALIDATION_PATTERN.matcher(data).matches()) {
|
||||
for (String status : data.split("&")) {
|
||||
String statusPart[] = status.split("=");
|
||||
String[] statusPart = status.split("=");
|
||||
int portNumShift = 1;
|
||||
PortDefinition portDefinition = PortDefinition.fromPortName(statusPart[0].substring(0, 1));
|
||||
switch (portDefinition) {
|
||||
|
||||
@@ -52,9 +52,9 @@ public class StatusFileInterpreter {
|
||||
|
||||
private Optional<Document> doc = Optional.empty();
|
||||
|
||||
public static enum StatusEntry {
|
||||
public enum StatusEntry {
|
||||
VERSION,
|
||||
CONFIG_MAC;
|
||||
CONFIG_MAC
|
||||
}
|
||||
|
||||
public StatusFileInterpreter(String hostname, Ipx800EventListener listener) {
|
||||
|
||||
Reference in New Issue
Block a user