Search in sources :

Example 1 with SystemBrokerHandler

use of org.eclipse.smarthome.binding.mqtt.handler.SystemBrokerHandler in project smarthome by eclipse.

the class MqttBrokerHandlerFactory method createHandler.

@Override
@Nullable
protected ThingHandler createHandler(Thing thing) {
    if (mqttService == null) {
        throw new IllegalStateException("MqttService must be bound, before ThingHandlers can be created");
    }
    if (!(thing instanceof Bridge)) {
        throw new IllegalStateException("A bridge type is expected");
    }
    final ThingTypeUID thingTypeUID = thing.getThingTypeUID();
    final AbstractBrokerHandler handler;
    if (thingTypeUID.equals(MqttBindingConstants.BRIDGE_TYPE_SYSTEMBROKER)) {
        handler = new SystemBrokerHandler((Bridge) thing, mqttService);
    } else if (thingTypeUID.equals(MqttBindingConstants.BRIDGE_TYPE_BROKER)) {
        handler = new BrokerHandler((Bridge) thing);
    } else {
        throw new IllegalStateException("Not supported " + thingTypeUID.toString());
    }
    createdHandler(handler);
    return handler;
}
Also used : SystemBrokerHandler(org.eclipse.smarthome.binding.mqtt.handler.SystemBrokerHandler) AbstractBrokerHandler(org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler) AbstractBrokerHandler(org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler) BrokerHandler(org.eclipse.smarthome.binding.mqtt.handler.BrokerHandler) SystemBrokerHandler(org.eclipse.smarthome.binding.mqtt.handler.SystemBrokerHandler) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) Bridge(org.eclipse.smarthome.core.thing.Bridge) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

Nullable (org.eclipse.jdt.annotation.Nullable)1 AbstractBrokerHandler (org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler)1 BrokerHandler (org.eclipse.smarthome.binding.mqtt.handler.BrokerHandler)1 SystemBrokerHandler (org.eclipse.smarthome.binding.mqtt.handler.SystemBrokerHandler)1 Bridge (org.eclipse.smarthome.core.thing.Bridge)1 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)1