|
14 | 14 |
|
15 | 15 | import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*;
|
16 | 16 |
|
17 |
| -import java.util.Set; |
18 |
| - |
19 | 17 | import org.eclipse.jdt.annotation.NonNullByDefault;
|
20 | 18 | import org.eclipse.jdt.annotation.Nullable;
|
21 | 19 | import org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler;
|
@@ -43,25 +41,22 @@ public class SystemInfoHandlerFactory extends BaseThingHandlerFactory {
|
43 | 41 | private @NonNullByDefault({}) SystemInfoInterface systeminfo;
|
44 | 42 | private @NonNullByDefault({}) SystemInfoThingTypeProvider thingTypeProvider;
|
45 | 43 |
|
46 |
| - private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_COMPUTER, |
47 |
| - THING_TYPE_COMPUTER_IMPL); |
48 |
| - |
49 | 44 | @Override
|
50 | 45 | 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); |
52 | 48 | }
|
53 | 49 |
|
54 | 50 | @Override
|
55 | 51 | protected @Nullable ThingHandler createHandler(Thing thing) {
|
56 |
| - if (THING_TYPE_COMPUTER.equals(thing.getThingTypeUID())) { |
| 52 | + ThingTypeUID thingTypeUID = thing.getThingTypeUID(); |
| 53 | + if (supportsThingType(thingTypeUID)) { |
57 | 54 | if (thingTypeProvider.getThingType(THING_TYPE_COMPUTER_IMPL, null) == null) {
|
58 | 55 | thingTypeProvider.createThingType(THING_TYPE_COMPUTER_IMPL);
|
59 | 56 | // Save the current channels configs, will be restored after thing type change.
|
60 | 57 | thingTypeProvider.storeChannelsConfig(thing);
|
61 | 58 | }
|
62 | 59 | return new SystemInfoHandler(thing, thingTypeProvider, systeminfo);
|
63 |
| - } else if (THING_TYPE_COMPUTER_IMPL.equals(thing.getThingTypeUID())) { |
64 |
| - return new SystemInfoHandler(thing, thingTypeProvider, systeminfo); |
65 | 60 | }
|
66 | 61 | return null;
|
67 | 62 | }
|
|
0 commit comments