public static final String BINDING_ID = "systeminfo";
- public static final ThingTypeUID THING_TYPE_COMPUTER = new ThingTypeUID(BINDING_ID, "computer");
- public static final ThingTypeUID THING_TYPE_COMPUTER_IMPL = new ThingTypeUID(BINDING_ID, "computer-impl");
+ public static final String THING_TYPE_COMPUTER_ID = "computer";
+ public static final ThingTypeUID THING_TYPE_COMPUTER = new ThingTypeUID(BINDING_ID, THING_TYPE_COMPUTER_ID);
+ public static final ThingTypeUID THING_TYPE_COMPUTER_IMPL = new ThingTypeUID(BINDING_ID,
+ THING_TYPE_COMPUTER_ID + "-impl");
// Thing properties
/**
import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*;
-import java.util.Set;
-
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler;
private @NonNullByDefault({}) SystemInfoInterface systeminfo;
private @NonNullByDefault({}) SystemInfoThingTypeProvider thingTypeProvider;
- private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_COMPUTER,
- THING_TYPE_COMPUTER_IMPL);
-
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
- return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
+ return BINDING_ID.equals(thingTypeUID.getBindingId())
+ && thingTypeUID.getId().startsWith(THING_TYPE_COMPUTER_ID);
}
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
- if (THING_TYPE_COMPUTER.equals(thing.getThingTypeUID())) {
+ ThingTypeUID thingTypeUID = thing.getThingTypeUID();
+ if (supportsThingType(thingTypeUID)) {
if (thingTypeProvider.getThingType(THING_TYPE_COMPUTER_IMPL, null) == null) {
thingTypeProvider.createThingType(THING_TYPE_COMPUTER_IMPL);
// Save the current channels configs, will be restored after thing type change.
thingTypeProvider.storeChannelsConfig(thing);
}
return new SystemInfoHandler(thing, thingTypeProvider, systeminfo);
- } else if (THING_TYPE_COMPUTER_IMPL.equals(thing.getThingTypeUID())) {
- return new SystemInfoHandler(thing, thingTypeProvider, systeminfo);
}
return null;
}