Java 17 features (T-Z) (#15576)

- 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-21 07:58:53 +02:00
committed by GitHub
parent bf1aa3deb2
commit 1b122a53b9
277 changed files with 1402 additions and 1298 deletions

View File

@@ -125,7 +125,6 @@ public class WolfSmartsetApi {
logger.trace("Login succeeded but failed to create session {}", loginFailedCounter);
return false;
}
} catch (WolfSmartsetCloudException e) {
logger.debug("Error logging on to Wolf Smartset ({}): {}", loginFailedCounter, e.getMessage());
loginFailedCounter++;

View File

@@ -56,8 +56,8 @@ public class WolfSmartsetAccountDiscoveryService extends AbstractDiscoveryServic
@Override
public void setThingHandler(@Nullable ThingHandler handler) {
if (handler instanceof WolfSmartsetAccountBridgeHandler) {
this.bridgeHandler = (WolfSmartsetAccountBridgeHandler) handler;
if (handler instanceof WolfSmartsetAccountBridgeHandler accountBridgeHandler) {
this.bridgeHandler = accountBridgeHandler;
}
}

View File

@@ -57,8 +57,8 @@ public class WolfSmartsetSystemDiscoveryService extends AbstractDiscoveryService
@Override
public void setThingHandler(@Nullable ThingHandler handler) {
if (handler instanceof WolfSmartsetSystemBridgeHandler) {
this.bridgeHandler = (WolfSmartsetSystemBridgeHandler) handler;
if (handler instanceof WolfSmartsetSystemBridgeHandler systemBridgeHandler) {
this.bridgeHandler = systemBridgeHandler;
}
}
@@ -151,7 +151,7 @@ public class WolfSmartsetSystemDiscoveryService extends AbstractDiscoveryService
properties.put(CONFIG_UNIT_ID, unit.menuItemTabViewDTO.bundleId.toString());
var tabName = unit.menuItemTabViewDTO.tabName;
var menuName = unit.subMenuEntryDTO.getName();
tabName = tabName.isEmpty() || tabName.equalsIgnoreCase("NULL") || menuName.equalsIgnoreCase(tabName) ? ""
tabName = tabName.isEmpty() || "NULL".equalsIgnoreCase(tabName) || menuName.equalsIgnoreCase(tabName) ? ""
: "-" + tabName;
return DiscoveryResultBuilder.create(unitUID).withProperties(properties)

View File

@@ -15,7 +15,6 @@ package org.openhab.binding.wolfsmartset.internal.handler;
import static org.openhab.binding.wolfsmartset.internal.WolfSmartsetBindingConstants.CONFIG_SYSTEM_ID;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -126,7 +125,7 @@ public class WolfSmartsetAccountBridgeHandler extends BaseBridgeHandler {
@Override
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(WolfSmartsetAccountDiscoveryService.class);
return Set.of(WolfSmartsetAccountDiscoveryService.class);
}
@Override
@@ -212,7 +211,7 @@ public class WolfSmartsetAccountBridgeHandler extends BaseBridgeHandler {
var systemConfigs = systemHandlers.values().stream().map(s -> s.getSystemConfig())
.filter(s -> s != null).collect(Collectors.toSet());
if (systemConfigs != null && systemConfigs.size() > 0) {
if (systemConfigs != null && !systemConfigs.isEmpty()) {
var systemStates = api.getSystemState(systemConfigs);
if (systemStates != null) {
for (var systemState : systemStates) {

View File

@@ -16,9 +16,9 @@ import static org.openhab.binding.wolfsmartset.internal.WolfSmartsetBindingConst
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -77,7 +77,7 @@ public class WolfSmartsetSystemBridgeHandler extends BaseBridgeHandler {
@Override
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(WolfSmartsetSystemDiscoveryService.class);
return Set.of(WolfSmartsetSystemDiscoveryService.class);
}
@Override