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

@@ -26,7 +26,7 @@ abstract class CommandPacket {
return res;
}
abstract protected void write(OutputStream stream) throws IOException;
protected abstract void write(OutputStream stream) throws IOException;
}
class CmdGetInfo extends CommandPacket {
@@ -210,7 +210,7 @@ abstract class EventPacket {
}
}
abstract protected void parseInternal(InputStream stream) throws IOException;
protected abstract void parseInternal(InputStream stream) throws IOException;
}
class EvtAdvertisementPacket extends EventPacket {
@@ -366,7 +366,7 @@ class EvtGetButtonInfoResponse extends EventPacket {
sb.append(String.format("%02x", uuidBytes[i]));
}
uuid = sb.toString();
if (uuid.equals("00000000000000000000000000000000")) {
if ("00000000000000000000000000000000".equals(uuid)) {
uuid = null;
}
color = StreamUtils.getString(stream, 16);

View File

@@ -36,8 +36,8 @@ public class FlicButtonBindingConstants {
public static final ThingTypeUID BRIDGE_THING_TYPE = new ThingTypeUID(BINDING_ID, "flicd-bridge");
public static final ThingTypeUID FLICBUTTON_THING_TYPE = new ThingTypeUID(BINDING_ID, "button");
public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Collections.singleton(BRIDGE_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(FLICBUTTON_THING_TYPE);
public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(FLICBUTTON_THING_TYPE);
// List of all configuration options
public static final String CONFIG_HOST_NAME = "hostname";

View File

@@ -14,7 +14,7 @@
package org.openhab.binding.flicbutton.internal.handler;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -34,8 +34,7 @@ import org.openhab.core.thing.binding.BridgeHandler;
*/
@NonNullByDefault
public abstract class ChildThingHandler<BridgeHandlerType extends BridgeHandler> extends BaseThingHandler {
private static final Collection<ThingStatus> DEFAULT_TOLERATED_BRIDGE_STATUSES = Collections
.singleton(ThingStatus.ONLINE);
private static final Collection<ThingStatus> DEFAULT_TOLERATED_BRIDGE_STATUSES = Set.of(ThingStatus.ONLINE);
protected boolean bridgeValid = false;
protected @Nullable BridgeHandlerType bridgeHandler;