Java 17 features (H-M) (#15520)

- 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
- remove null check before instanceof

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich
2023-09-08 14:36:59 +02:00
committed by GitHub
parent 3751fd0646
commit edaf17b345
519 changed files with 2703 additions and 2660 deletions

View File

@@ -13,7 +13,6 @@
package org.openhab.binding.hyperion.internal;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -39,7 +38,7 @@ public class HyperionDiscoveryParticipant implements MDNSDiscoveryParticipant {
@Override
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
return Collections.singleton(HyperionBindingConstants.THING_TYPE_SERVER_NG);
return Set.of(HyperionBindingConstants.THING_TYPE_SERVER_NG);
}
@Override

View File

@@ -68,8 +68,6 @@ public class JsonTcpConnection {
outToServer.writeBytes(json + System.lineSeparator());
outToServer.flush();
response = inFromServer.readLine();
} catch (IOException e) {
throw e;
}
logger.debug("Received: {}", response);
return response;

View File

@@ -255,10 +255,9 @@ public class HyperionHandler extends BaseThingHandler {
}
private void handleBrightness(Command command) throws IOException, CommandUnsuccessfulException {
if (command instanceof PercentType) {
PercentType percent = (PercentType) command;
if (command instanceof PercentType percentCommand) {
Transform transform = new Transform();
transform.setLuminanceGain(percent.doubleValue() / 100);
transform.setLuminanceGain(percentCommand.doubleValue() / 100);
TransformCommand transformCommand = new TransformCommand(transform);
sendCommand(transformCommand);
} else {
@@ -267,9 +266,8 @@ public class HyperionHandler extends BaseThingHandler {
}
private void handleColor(Command command) throws IOException, CommandUnsuccessfulException {
if (command instanceof HSBType) {
HSBType color = (HSBType) command;
Color c = new Color(color.getRGB());
if (command instanceof HSBType hsbCommand) {
Color c = new Color(hsbCommand.getRGB());
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();

View File

@@ -176,7 +176,6 @@ public class HyperionNgHandler extends BaseThingHandler {
// update Hyperion, older API compatibility
Hyperion hyperion = info.getHyperion();
if (hyperion != null) {
updateHyperion(hyperion);
}
@@ -422,9 +421,8 @@ public class HyperionNgHandler extends BaseThingHandler {
}
private void handleBrightness(Command command) throws IOException, CommandUnsuccessfulException {
if (command instanceof PercentType) {
PercentType percent = (PercentType) command;
int brightnessValue = percent.intValue();
if (command instanceof PercentType percentCommand) {
int brightnessValue = percentCommand.intValue();
Adjustment adjustment = new Adjustment();
adjustment.setBrightness(brightnessValue);
@@ -437,9 +435,8 @@ public class HyperionNgHandler extends BaseThingHandler {
}
private void handleColor(Command command) throws IOException, CommandUnsuccessfulException {
if (command instanceof HSBType) {
HSBType color = (HSBType) command;
Color c = new Color(color.getRGB());
if (command instanceof HSBType hsbCommand) {
Color c = new Color(hsbCommand.getRGB());
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();