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

@@ -48,8 +48,8 @@ public class LeapMotionColorProfile implements TriggerProfile {
@Override
public void onStateUpdateFromItem(State state) {
if (state instanceof HSBType) {
lastState = (HSBType) state;
if (state instanceof HSBType hsbState) {
lastState = hsbState;
} else {
PercentType currentBrightness = state.as(PercentType.class);
if (currentBrightness != null) {
@@ -94,7 +94,6 @@ public class LeapMotionColorProfile implements TriggerProfile {
int hue = clockwise ? (color.getHue().toBigDecimal().intValue() - 20 + 360) % 360
: (color.getHue().toBigDecimal().intValue() + 20 + 360) % 360;
logger.debug("New hue value: {}", hue);
HSBType newState = new HSBType(new DecimalType(hue), color.getSaturation(), color.getBrightness());
return newState;
return new HSBType(new DecimalType(hue), color.getSaturation(), color.getBrightness());
}
}

View File

@@ -14,7 +14,6 @@ package org.openhab.binding.leapmotion.internal;
import static org.openhab.binding.leapmotion.internal.LeapMotionBindingConstants.THING_TYPE_CONTROLLER;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -36,7 +35,7 @@ import org.osgi.service.component.annotations.Component;
@NonNullByDefault
public class LeapMotionHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_CONTROLLER);
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_CONTROLLER);
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {

View File

@@ -12,8 +12,8 @@
*/
package org.openhab.binding.leapmotion.internal.discovery;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -42,7 +42,7 @@ public class LeapMotionDiscoveryService extends AbstractDiscoveryService {
private @NonNullByDefault({}) Listener listener;
public LeapMotionDiscoveryService() throws IllegalArgumentException {
super(Collections.singleton(LeapMotionBindingConstants.THING_TYPE_CONTROLLER), 10, true);
super(Set.of(LeapMotionBindingConstants.THING_TYPE_CONTROLLER), 10, true);
}
@Override