Java 17 features (N-S) (#15565)

- 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:
Holger Friedrich
2023-09-13 08:03:31 +02:00
committed by GitHub
parent 641b482551
commit ab58f4ffb4
471 changed files with 1624 additions and 1868 deletions

View File

@@ -41,8 +41,7 @@ public final class RequestResponseFactory {
* @return
*/
public static SimpleCommand getIpControlCommand(SimpleCommandType command) {
SimpleCommand result = new SimpleCommand(command);
return result;
return new SimpleCommand(command);
}
/**
@@ -53,8 +52,7 @@ public final class RequestResponseFactory {
* @return
*/
public static SimpleCommand getIpControlCommand(SimpleCommandType command, int zone) {
SimpleCommand result = new SimpleCommand(command, zone);
return result;
return new SimpleCommand(command, zone);
}
/**
@@ -65,8 +63,7 @@ public final class RequestResponseFactory {
* @return
*/
public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command) {
ParameterizedCommand result = new ParameterizedCommand(command);
return result;
return new ParameterizedCommand(command);
}
/**
@@ -78,8 +75,7 @@ public final class RequestResponseFactory {
* @return
*/
public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, int zone) {
ParameterizedCommand result = new ParameterizedCommand(command, zone);
return result;
return new ParameterizedCommand(command, zone);
}
/**

View File

@@ -44,7 +44,7 @@ public class SimpleCommand implements AvrCommand {
MCACC_MEMORY_CHANGE_CYCLIC("0MC"),
MCACC_MEMORY_QUERY("?MC");
private String zoneCommands[];
private String[] zoneCommands;
private SimpleCommandType(String... command) {
this.zoneCommands = command;

View File

@@ -240,14 +240,14 @@ public abstract class StreamAvrConnection implements AvrConnection {
commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.VOLUME_DOWN, zone);
} else if (command == IncreaseDecreaseType.INCREASE) {
commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.VOLUME_UP, zone);
} else if (command instanceof PercentType) {
} else if (command instanceof PercentType percentCommand) {
String ipControlVolume = VolumeConverter
.convertFromPercentToIpControlVolume(((PercentType) command).doubleValue(), zone);
.convertFromPercentToIpControlVolume(percentCommand.doubleValue(), zone);
commandToSend = RequestResponseFactory.getIpControlCommand(ParameterizedCommandType.VOLUME_SET, zone)
.setParameter(ipControlVolume);
} else if (command instanceof DecimalType) {
String ipControlVolume = VolumeConverter
.convertFromDbToIpControlVolume(((DecimalType) command).doubleValue(), zone);
} else if (command instanceof DecimalType decimalCommand) {
String ipControlVolume = VolumeConverter.convertFromDbToIpControlVolume(decimalCommand.doubleValue(),
zone);
commandToSend = RequestResponseFactory.getIpControlCommand(ParameterizedCommandType.VOLUME_SET, zone)
.setParameter(ipControlVolume);
} else {
@@ -267,8 +267,8 @@ public abstract class StreamAvrConnection implements AvrConnection {
commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.INPUT_CHANGE_CYCLIC, zone);
} else if (command == IncreaseDecreaseType.DECREASE) {
commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.INPUT_CHANGE_REVERSE, zone);
} else if (command instanceof StringType) {
String inputSourceValue = ((StringType) command).toString();
} else if (command instanceof StringType stringCommand) {
String inputSourceValue = stringCommand.toString();
commandToSend = RequestResponseFactory.getIpControlCommand(ParameterizedCommandType.INPUT_CHANNEL_SET, zone)
.setParameter(inputSourceValue);
} else {
@@ -285,8 +285,8 @@ public abstract class StreamAvrConnection implements AvrConnection {
if (command == IncreaseDecreaseType.INCREASE) {
commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.LISTENING_MODE_CHANGE_CYCLIC,
zone);
} else if (command instanceof StringType) {
String listeningModeValue = ((StringType) command).toString();
} else if (command instanceof StringType stringCommand) {
String listeningModeValue = stringCommand.toString();
commandToSend = RequestResponseFactory
.getIpControlCommand(ParameterizedCommandType.LISTENING_MODE_SET, zone)
.setParameter(listeningModeValue);
@@ -318,8 +318,8 @@ public abstract class StreamAvrConnection implements AvrConnection {
if (command == IncreaseDecreaseType.INCREASE) {
commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.MCACC_MEMORY_CHANGE_CYCLIC);
} else if (command instanceof StringType) {
String MCACCMemoryValue = ((StringType) command).toString();
} else if (command instanceof StringType stringCommand) {
String MCACCMemoryValue = stringCommand.toString();
commandToSend = RequestResponseFactory.getIpControlCommand(ParameterizedCommandType.MCACC_MEMORY_SET)
.setParameter(MCACCMemoryValue);
} else {