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:
@@ -194,8 +194,7 @@ public class BlueZBridgeHandler extends AbstractBluetoothBridgeHandler<BlueZBlue
|
||||
@Override
|
||||
protected BlueZBluetoothDevice createDevice(BluetoothAddress address) {
|
||||
logger.debug("createDevice {}", address);
|
||||
BlueZBluetoothDevice device = new BlueZBluetoothDevice(this, address);
|
||||
return device;
|
||||
return new BlueZBluetoothDevice(this, address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.bluetooth.bluez.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BlueZDiscoveryService extends AbstractDiscoveryService {
|
||||
|
||||
@Activate
|
||||
public BlueZDiscoveryService(@Reference DeviceManagerFactory deviceManagerFactory) {
|
||||
super(Collections.singleton(BlueZAdapterConstants.THING_TYPE_BLUEZ), 1, true);
|
||||
super(Set.of(BlueZAdapterConstants.THING_TYPE_BLUEZ), 1, true);
|
||||
this.deviceManagerFactory = deviceManagerFactory;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.bluetooth.bluez.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
@@ -45,8 +44,7 @@ import org.osgi.service.component.annotations.Reference;
|
||||
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.bluetooth.bluez")
|
||||
public class BlueZHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
|
||||
.singleton(BlueZAdapterConstants.THING_TYPE_BLUEZ);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(BlueZAdapterConstants.THING_TYPE_BLUEZ);
|
||||
|
||||
private final Map<ThingUID, ServiceRegistration<?>> serviceRegs = new HashMap<>();
|
||||
|
||||
@@ -82,8 +80,8 @@ public class BlueZHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
@Override
|
||||
protected synchronized void removeHandler(ThingHandler thingHandler) {
|
||||
if (thingHandler instanceof BluetoothAdapter) {
|
||||
UID uid = ((BluetoothAdapter) thingHandler).getUID();
|
||||
if (thingHandler instanceof BluetoothAdapter bluetoothAdapter) {
|
||||
UID uid = bluetoothAdapter.getUID();
|
||||
ServiceRegistration<?> serviceReg = this.serviceRegs.remove(uid);
|
||||
if (serviceReg != null) {
|
||||
serviceReg.unregister();
|
||||
|
||||
Reference in New Issue
Block a user