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:
@@ -58,9 +58,9 @@ public class NUTChannelTypeProvider implements ChannelTypeProvider, ThingHandler
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable final ThingHandler handler) {
|
||||
if (handler instanceof NUTHandler) {
|
||||
if (handler instanceof NUTHandler nutHandler) {
|
||||
this.handler = handler;
|
||||
((NUTHandler) handler).setChannelTypeProvider(this);
|
||||
nutHandler.setChannelTypeProvider(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ package org.openhab.binding.networkupstools.internal;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -112,7 +112,7 @@ public class NUTHandler extends BaseThingHandler {
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(NUTChannelTypeProvider.class);
|
||||
return Set.of(NUTChannelTypeProvider.class);
|
||||
}
|
||||
|
||||
public void setChannelTypeProvider(final NUTChannelTypeProvider channelTypeProvider) {
|
||||
|
||||
@@ -14,7 +14,6 @@ package org.openhab.binding.networkupstools.internal;
|
||||
|
||||
import static org.openhab.binding.networkupstools.internal.NUTBindingConstants.THING_TYPE_UPS;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -35,7 +34,7 @@ import org.osgi.service.component.annotations.Component;
|
||||
@Component(configurationPid = "binding.networkupstools", service = ThingHandlerFactory.class)
|
||||
public class NUTHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_UPS);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_UPS);
|
||||
|
||||
@Override
|
||||
public boolean supportsThingType(final ThingTypeUID thingTypeUID) {
|
||||
|
||||
Reference in New Issue
Block a user