Package org.openhab.core.thing.events
Class ThingEventFactory
java.lang.Object
org.openhab.core.events.AbstractEventFactory
org.openhab.core.thing.events.ThingEventFactory
- All Implemented Interfaces:
EventFactory
A
ThingEventFactory is responsible for creating thing event instances:
- Author:
- Stefan Bußweiler - Initial contribution, Dennis Nobel - Added status changed event, Christoph Weitkamp - Added ChannelDescriptionChangedEvent
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic interfacestatic classThis is a java bean that is used to serialize/deserialize trigger event payload. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ThingAddedEventcreateAddedEvent(Thing thing) Creates a thing added event.createChannelDescriptionChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, StateDescriptionFragment stateDescription, @Nullable StateDescriptionFragment oldStateDescription) Creates aChannelDescriptionChangedEventfor a changedStateDescription.createChannelDescriptionCommandOptionsChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, List<CommandOption> options, @Nullable List<CommandOption> oldOptions) Creates aChannelDescriptionChangedEventfor changeCommandOptions.createChannelDescriptionPatternChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, String pattern, @Nullable String oldPattern) Creates aChannelDescriptionChangedEventfor a changed pattern.createChannelDescriptionStateOptionsChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, List<StateOption> options, @Nullable List<StateOption> oldOptions) Creates aChannelDescriptionChangedEventfor changedStateOptions.protected EventcreateEventByType(String eventType, String topic, String payload, @Nullable String source) Create a new event instance based on the event type.static ThingRemovedEventcreateRemovedEvent(Thing thing) Creates a thing removed event.static ThingStatusInfoChangedEventcreateStatusInfoChangedEvent(ThingUID thingUID, ThingStatusInfo thingStatusInfo, ThingStatusInfo oldThingStatusInfo) Creates a new thing status info changed event based on a thing UID, a thing status info and the old thing status info object.static ThingStatusInfoEventcreateStatusInfoEvent(ThingUID thingUID, ThingStatusInfo thingStatusInfo) Creates a new thing status info event based on a thing UID and a thing status info object.static ChannelTriggeredEventcreateTriggerEvent(String event, ChannelUID channelUID) Creates aChannelTriggeredEventstatic ThingUpdatedEventcreateUpdateEvent(Thing thing, Thing oldThing) Creates a thing updated event.Methods inherited from class org.openhab.core.events.AbstractEventFactory
checkNotNull, checkNotNullOrEmpty, createEvent, deserializePayload, getSupportedEventTypes, getTopicElements, serializePayload
-
Constructor Details
-
ThingEventFactory
public ThingEventFactory()Constructs a new ThingEventFactory.
-
-
Method Details
-
createEventByType
protected Event createEventByType(String eventType, String topic, String payload, @Nullable String source) throws Exception Description copied from class:AbstractEventFactoryCreate a new event instance based on the event type.- Specified by:
createEventByTypein classAbstractEventFactory- Parameters:
eventType- the event typetopic- the topicpayload- the payloadsource- the source, can be null- Returns:
- the created event instance
- Throws:
Exception- if the creation of the event fails
-
createChannelDescriptionChangedEvent
public static ChannelDescriptionChangedEvent createChannelDescriptionChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, StateDescriptionFragment stateDescription, @Nullable StateDescriptionFragment oldStateDescription) Creates aChannelDescriptionChangedEventfor a changedStateDescription. New and optional old value will be serialized to a JSON string from theStateDescriptionFragmentobject.- Parameters:
channelUID- theChannelUIDlinkedItemNames- aSetof linked item namesstateDescription- the newStateDescriptionFragmentoldStateDescription- the oldStateDescriptionFragment- Returns:
- Created
ChannelDescriptionChangedEvent
-
createChannelDescriptionPatternChangedEvent
public static ChannelDescriptionChangedEvent createChannelDescriptionPatternChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, String pattern, @Nullable String oldPattern) Creates aChannelDescriptionChangedEventfor a changed pattern. New and optional old value will be serialized to a JSON string from theThingEventFactory.ChannelDescriptionPatternPayloadBeanobject.- Parameters:
channelUID- theChannelUIDlinkedItemNames- aSetof linked item namespattern- the new patternoldPattern- the old pattern- Returns:
- Created
ChannelDescriptionChangedEvent
-
createChannelDescriptionStateOptionsChangedEvent
public static ChannelDescriptionChangedEvent createChannelDescriptionStateOptionsChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, List<StateOption> options, @Nullable List<StateOption> oldOptions) Creates aChannelDescriptionChangedEventfor changedStateOptions. New and optional old value will be serialized to a JSON string from theThingEventFactory.ChannelDescriptionStateOptionsPayloadBeanobject.- Parameters:
channelUID- theChannelUIDlinkedItemNames- aSetof linked item namesoptions- the newStateOptionsoldOptions- the oldStateOptions- Returns:
- Created
ChannelDescriptionChangedEvent
-
createChannelDescriptionCommandOptionsChangedEvent
public static ChannelDescriptionChangedEvent createChannelDescriptionCommandOptionsChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, List<CommandOption> options, @Nullable List<CommandOption> oldOptions) Creates aChannelDescriptionChangedEventfor changeCommandOptions. New and optional old value will be serialized to a JSON string from theThingEventFactory.ChannelDescriptionCommandOptionsPayloadBeanobject.- Parameters:
channelUID- theChannelUIDlinkedItemNames- aSetof linked item namesoptions- the newCommandOptionsoldOptions- the oldCommandOptions- Returns:
- Created
ChannelDescriptionChangedEvent
-
createTriggerEvent
Creates aChannelTriggeredEvent- Parameters:
event- the eventchannelUID- theChannelUID- Returns:
- Created
ChannelTriggeredEvent
-
createStatusInfoEvent
public static ThingStatusInfoEvent createStatusInfoEvent(ThingUID thingUID, ThingStatusInfo thingStatusInfo) Creates a new thing status info event based on a thing UID and a thing status info object.- Parameters:
thingUID- the thing UIDthingStatusInfo- the thing status info object- Returns:
- the created thing status info event
- Throws:
IllegalArgumentException- if thingUID or thingStatusInfo is null
-
createStatusInfoChangedEvent
public static ThingStatusInfoChangedEvent createStatusInfoChangedEvent(ThingUID thingUID, ThingStatusInfo thingStatusInfo, ThingStatusInfo oldThingStatusInfo) Creates a new thing status info changed event based on a thing UID, a thing status info and the old thing status info object.- Parameters:
thingUID- the thing UIDthingStatusInfo- the thing status info objectoldThingStatusInfo- the old thing status info object- Returns:
- the created thing status info changed event
- Throws:
IllegalArgumentException- if thingUID or thingStatusInfo is null
-
createAddedEvent
Creates a thing added event.- Parameters:
thing- the thing- Returns:
- the created thing added event
- Throws:
IllegalArgumentException- if thing is null
-
createRemovedEvent
Creates a thing removed event.- Parameters:
thing- the thing- Returns:
- the created thing removed event
- Throws:
IllegalArgumentException- if thing is null
-
createUpdateEvent
Creates a thing updated event.- Parameters:
thing- the thingoldThing- the old thing- Returns:
- the created thing updated event
- Throws:
IllegalArgumentException- if thing or oldThing is null
-