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:
Holger Friedrich
2023-09-05 22:30:16 +02:00
committed by GitHub
parent a0dc5c05f2
commit cf10b3e9c7
486 changed files with 2053 additions and 1955 deletions

View File

@@ -104,13 +104,13 @@ public class EcoTouchConnector {
cause = e.toString();
}
if (line2 != null && line2.trim().equals("#E_USER_DONT_EXIST")) {
if (line2 != null && "#E_USER_DONT_EXIST".equals(line2.trim())) {
throw new IOException("Username does not exist.");
}
if (line2 != null && line2.trim().equals("#E_PASS_DONT_MATCH")) {
if (line2 != null && "#E_PASS_DONT_MATCH".equals(line2.trim())) {
throw new IOException("Password does not match.");
}
if (line2 != null && line2.trim().equals("#E_TOO_MANY_USERS")) {
if (line2 != null && "#E_TOO_MANY_USERS".equals(line2.trim())) {
throw new IOException("Too many users already logged in.");
}
if (cookies == null) {

View File

@@ -122,10 +122,8 @@ public class EcoTouchHandler extends BaseThingHandler {
localConnector.setValue(ecoTouchTag.getTagName(), raw);
} else {
if (ecoTouchTag.getUnit() != ONE) {
if (command instanceof QuantityType) {
// convert from user unit to heat pump unit
QuantityType<?> value = (QuantityType<?>) command;
QuantityType<?> rawUnit = value.toUnit(ecoTouchTag.getUnit());
if (command instanceof QuantityType quantityCommand) {
QuantityType<?> rawUnit = quantityCommand.toUnit(ecoTouchTag.getUnit());
if (rawUnit != null) {
int raw = (int) (rawUnit.doubleValue() * ecoTouchTag.getDivisor());
localConnector.setValue(ecoTouchTag.getTagName(), raw);