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
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
static interface
static class
This is a java bean that is used to serialize/deserialize trigger event payload. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ThingAddedEvent
createAddedEvent
(Thing thing) Creates a thing added event.createChannelDescriptionChangedEvent
(ChannelUID channelUID, Set<String> linkedItemNames, StateDescriptionFragment stateDescription, @Nullable StateDescriptionFragment oldStateDescription) Creates aChannelDescriptionChangedEvent
for a changedStateDescription
.createChannelDescriptionCommandOptionsChangedEvent
(ChannelUID channelUID, Set<String> linkedItemNames, List<CommandOption> options, @Nullable List<CommandOption> oldOptions) Creates aChannelDescriptionChangedEvent
for changeCommandOption
s.createChannelDescriptionPatternChangedEvent
(ChannelUID channelUID, Set<String> linkedItemNames, String pattern, @Nullable String oldPattern) Creates aChannelDescriptionChangedEvent
for a changed pattern.createChannelDescriptionStateOptionsChangedEvent
(ChannelUID channelUID, Set<String> linkedItemNames, List<StateOption> options, @Nullable List<StateOption> oldOptions) Creates aChannelDescriptionChangedEvent
for changedStateOption
s.protected Event
createEventByType
(String eventType, String topic, String payload, @Nullable String source) Create a new event instance based on the event type.static ThingRemovedEvent
createRemovedEvent
(Thing thing) Creates a thing removed event.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.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.static ChannelTriggeredEvent
createTriggerEvent
(String event, ChannelUID channelUID) Creates aChannelTriggeredEvent
static ThingUpdatedEvent
createUpdateEvent
(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:AbstractEventFactory
Create a new event instance based on the event type.- Specified by:
createEventByType
in 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 aChannelDescriptionChangedEvent
for a changedStateDescription
. New and optional old value will be serialized to a JSON string from theStateDescriptionFragment
object.- Parameters:
channelUID
- theChannelUID
linkedItemNames
- aSet
of linked item namesstateDescription
- the newStateDescriptionFragment
oldStateDescription
- the oldStateDescriptionFragment
- Returns:
- Created
ChannelDescriptionChangedEvent
-
createChannelDescriptionPatternChangedEvent
public static ChannelDescriptionChangedEvent createChannelDescriptionPatternChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, String pattern, @Nullable String oldPattern) Creates aChannelDescriptionChangedEvent
for a changed pattern. New and optional old value will be serialized to a JSON string from theThingEventFactory.ChannelDescriptionPatternPayloadBean
object.- Parameters:
channelUID
- theChannelUID
linkedItemNames
- aSet
of 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 aChannelDescriptionChangedEvent
for changedStateOption
s. New and optional old value will be serialized to a JSON string from theThingEventFactory.ChannelDescriptionStateOptionsPayloadBean
object.- Parameters:
channelUID
- theChannelUID
linkedItemNames
- aSet
of linked item namesoptions
- the newStateOption
soldOptions
- the oldStateOption
s- Returns:
- Created
ChannelDescriptionChangedEvent
-
createChannelDescriptionCommandOptionsChangedEvent
public static ChannelDescriptionChangedEvent createChannelDescriptionCommandOptionsChangedEvent(ChannelUID channelUID, Set<String> linkedItemNames, List<CommandOption> options, @Nullable List<CommandOption> oldOptions) Creates aChannelDescriptionChangedEvent
for changeCommandOption
s. New and optional old value will be serialized to a JSON string from theThingEventFactory.ChannelDescriptionCommandOptionsPayloadBean
object.- Parameters:
channelUID
- theChannelUID
linkedItemNames
- aSet
of linked item namesoptions
- the newCommandOption
soldOptions
- the oldCommandOption
s- 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
-