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:
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.silvercrestwifisocket.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -47,7 +46,7 @@ public class SilvercrestWifiSocketBindingConstants {
|
||||
/**
|
||||
* The supported thing types.
|
||||
*/
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_WIFI_SOCKET);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_WIFI_SOCKET);
|
||||
|
||||
// -------------- Configuration arguments ----------------
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.silvercrestwifisocket.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openhab.binding.silvercrestwifisocket.internal.exceptions.MacAddressNotValidException;
|
||||
@@ -37,8 +36,8 @@ import org.slf4j.LoggerFactory;
|
||||
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.silvercrestwifisocket")
|
||||
public class SilvercrestWifiSocketHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
|
||||
.singleton(SilvercrestWifiSocketBindingConstants.THING_TYPE_WIFI_SOCKET);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set
|
||||
.of(SilvercrestWifiSocketBindingConstants.THING_TYPE_WIFI_SOCKET);
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SilvercrestWifiSocketHandlerFactory.class);
|
||||
|
||||
|
||||
@@ -180,11 +180,11 @@ public class SilvercrestWifiSocketHandler extends BaseThingHandler {
|
||||
// if the host of the packet is different from the host address set in handler, update the host
|
||||
// address.
|
||||
if (!receivedMessage.getHostAddress().equals(this.hostAddress)) {
|
||||
logger.debug(
|
||||
"The host of the packet is different from the host address set in handler. "
|
||||
+ "Will update the host address. handler of mac: {}. "
|
||||
+ "Old host address: '{}' -> new host address: '{}'",
|
||||
this.macAddress, this.hostAddress, receivedMessage.getHostAddress());
|
||||
logger.debug("""
|
||||
The host of the packet is different from the host address set in handler. \
|
||||
Will update the host address. handler of mac: {}. \
|
||||
Old host address: '{}' -> new host address: '{}'\
|
||||
""", this.macAddress, this.hostAddress, receivedMessage.getHostAddress());
|
||||
|
||||
this.hostAddress = receivedMessage.getHostAddress();
|
||||
this.saveConfigurationsUsingCurrentStates();
|
||||
@@ -252,7 +252,7 @@ public class SilvercrestWifiSocketHandler extends BaseThingHandler {
|
||||
if (ValidationUtils.isMacNotValid(macAddress)) {
|
||||
throw new MacAddressNotValidException("Mac address is not valid", macAddress);
|
||||
}
|
||||
this.macAddress = macAddress.replaceAll(":", "").toUpperCase();
|
||||
this.macAddress = macAddress.replace(":", "").toUpperCase();
|
||||
}
|
||||
if (this.macAddress == null) {
|
||||
throw new MacAddressNotValidException("Mac address is not valid", this.macAddress);
|
||||
|
||||
Reference in New Issue
Block a user