Java 17 features (#15493)

- 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

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich
2023-08-26 08:52:11 +02:00
committed by GitHub
parent d36833feef
commit 5b42c4b071
26 changed files with 79 additions and 82 deletions

View File

@@ -57,10 +57,10 @@ public class HomekitCommandExtension extends AbstractConsoleCommandExtension {
private static final String PARAM_INSTANCE_HELP = " [--instance <instance id>]";
private class CommandCompleter implements ConsoleCommandCompleter {
@Override
public boolean complete(String[] args, int cursorArgumentIndex, int cursorPosition, List<String> candidates) {
if (cursorArgumentIndex == 0) {
boolean result = SUBCMD_COMPLETER.complete(args, cursorArgumentIndex, cursorPosition, candidates);
return result;
return SUBCMD_COMPLETER.complete(args, cursorArgumentIndex, cursorPosition, candidates);
}
return false;
}

View File

@@ -506,6 +506,7 @@ public class HomekitTaggedItem {
return id;
}
@Override
public String toString() {
return "Item:" + proxyItem.getItem() + " HomeKit type: '" + homekitAccessoryType.getTag()
+ "' characteristic: '" + homekitCharacteristicType.getTag() + "'";

View File

@@ -437,7 +437,7 @@ public abstract class AbstractHomekitAccessoryImpl implements HomekitAccessory {
// Need to copy over everything except the current value, which we instead
// reach in and get the default value
cJson.forEach((k, v) -> {
if (k.equals("value")) {
if ("value".equals(k)) {
Object defaultValue = ((BaseCharacteristic) c).getDefault();
if (defaultValue instanceof Boolean) {
cBuilder.add("value", (boolean) defaultValue);

View File

@@ -98,7 +98,7 @@ public class BooleanItemReader {
} else if (state instanceof OpenClosedType) {
return state.equals(trueOpenClosedValue);
} else if (state instanceof StringType) {
return state.toString().equalsIgnoreCase("Open") || state.toString().equalsIgnoreCase("Opened");
return "Open".equalsIgnoreCase(state.toString()) || "Opened".equalsIgnoreCase(state.toString());
} else if (localTrueThresheold != null) {
if (state instanceof DecimalType stateAsDecimalType) {
final boolean result = stateAsDecimalType.toBigDecimal().compareTo(localTrueThresheold) > 0;