Skip to content

Commit 74b7612

Browse files
authored
fix startup (openhab#16971)
Signed-off-by: Mark Herwege <[email protected]>
1 parent 11326e7 commit 74b7612

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoBindingConstants.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ public class SystemInfoBindingConstants {
2828

2929
public static final String BINDING_ID = "systeminfo";
3030

31-
public static final ThingTypeUID THING_TYPE_COMPUTER = new ThingTypeUID(BINDING_ID, "computer");
32-
public static final ThingTypeUID THING_TYPE_COMPUTER_IMPL = new ThingTypeUID(BINDING_ID, "computer-impl");
31+
public static final String THING_TYPE_COMPUTER_ID = "computer";
32+
public static final ThingTypeUID THING_TYPE_COMPUTER = new ThingTypeUID(BINDING_ID, THING_TYPE_COMPUTER_ID);
33+
public static final ThingTypeUID THING_TYPE_COMPUTER_IMPL = new ThingTypeUID(BINDING_ID,
34+
THING_TYPE_COMPUTER_ID + "-impl");
3335

3436
// Thing properties
3537
/**

bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoHandlerFactory.java

+4-9
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*;
1616

17-
import java.util.Set;
18-
1917
import org.eclipse.jdt.annotation.NonNullByDefault;
2018
import org.eclipse.jdt.annotation.Nullable;
2119
import org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler;
@@ -43,25 +41,22 @@ public class SystemInfoHandlerFactory extends BaseThingHandlerFactory {
4341
private @NonNullByDefault({}) SystemInfoInterface systeminfo;
4442
private @NonNullByDefault({}) SystemInfoThingTypeProvider thingTypeProvider;
4543

46-
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_COMPUTER,
47-
THING_TYPE_COMPUTER_IMPL);
48-
4944
@Override
5045
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
51-
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
46+
return BINDING_ID.equals(thingTypeUID.getBindingId())
47+
&& thingTypeUID.getId().startsWith(THING_TYPE_COMPUTER_ID);
5248
}
5349

5450
@Override
5551
protected @Nullable ThingHandler createHandler(Thing thing) {
56-
if (THING_TYPE_COMPUTER.equals(thing.getThingTypeUID())) {
52+
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
53+
if (supportsThingType(thingTypeUID)) {
5754
if (thingTypeProvider.getThingType(THING_TYPE_COMPUTER_IMPL, null) == null) {
5855
thingTypeProvider.createThingType(THING_TYPE_COMPUTER_IMPL);
5956
// Save the current channels configs, will be restored after thing type change.
6057
thingTypeProvider.storeChannelsConfig(thing);
6158
}
6259
return new SystemInfoHandler(thing, thingTypeProvider, systeminfo);
63-
} else if (THING_TYPE_COMPUTER_IMPL.equals(thing.getThingTypeUID())) {
64-
return new SystemInfoHandler(thing, thingTypeProvider, systeminfo);
6560
}
6661
return null;
6762
}

0 commit comments

Comments
 (0)