Package org.openhab.core.items.events
Class ItemEventFactory
java.lang.Object
org.openhab.core.events.AbstractEventFactory
org.openhab.core.items.events.ItemEventFactory
- All Implemented Interfaces:
EventFactory
An
ItemEventFactory
is responsible for creating item event instances, e.g. ItemCommandEvent
s and
ItemStateEvent
s.- Author:
- Stefan Bußweiler - Initial contribution
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ItemAddedEvent
createAddedEvent
(Item item) Creates an item added event.static ItemCommandEvent
createCommandEvent
(String itemName, Command command) Creates an item command event.static ItemCommandEvent
createCommandEvent
(String itemName, Command command, @Nullable String source) Creates an item command event.protected Event
createEventByType
(String eventType, String topic, String payload, @Nullable String source) Create a new event instance based on the event type.static GroupItemStateChangedEvent
createGroupStateChangedEvent
(String itemName, String memberName, State newState, State oldState) Creates a group item state changed event.static GroupStateUpdatedEvent
createGroupStateUpdatedEvent
(String groupName, String member, State state, @Nullable String source) Creates a group item state updated event.static ItemRemovedEvent
createRemovedEvent
(Item item) Creates an item removed event.static ItemStateChangedEvent
createStateChangedEvent
(String itemName, State newState, State oldState) Creates an item state changed event.static ItemEvent
createStateEvent
(String itemName, State state) Creates an item state event.static ItemStateEvent
createStateEvent
(String itemName, State state, @Nullable String source) Creates an item state event.static ItemStatePredictedEvent
createStatePredictedEvent
(String itemName, State state, boolean isConfirmation) Creates an item state predicted event.static ItemStateUpdatedEvent
createStateUpdatedEvent
(String itemName, State state) Creates an item state updated event.static ItemStateUpdatedEvent
createStateUpdatedEvent
(String itemName, State state, @Nullable String source) Creates an item state updated event.static ItemTimeSeriesEvent
createTimeSeriesEvent
(String itemName, TimeSeries timeSeries, @Nullable String source) static ItemTimeSeriesUpdatedEvent
createTimeSeriesUpdatedEvent
(String itemName, TimeSeries timeSeries, @Nullable String source) static ItemUpdatedEvent
createUpdateEvent
(Item item, Item oldItem) Creates an item updated event.Methods inherited from class org.openhab.core.events.AbstractEventFactory
checkNotNull, checkNotNullOrEmpty, createEvent, deserializePayload, getSupportedEventTypes, getTopicElements, serializePayload
-
Constructor Details
-
ItemEventFactory
public ItemEventFactory()Constructs a new ItemEventFactory.
-
-
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
-
createCommandEvent
public static ItemCommandEvent createCommandEvent(String itemName, Command command, @Nullable String source) Creates an item command event.- Parameters:
itemName
- the name of the item to send the command forcommand
- the command to sendsource
- the name of the source identifying the sender (can be null)- Returns:
- the created item command event
- Throws:
IllegalArgumentException
- if itemName or command is null
-
createCommandEvent
Creates an item command event.- Parameters:
itemName
- the name of the item to send the command forcommand
- the command to send- Returns:
- the created item command event
- Throws:
IllegalArgumentException
- if itemName or command is null
-
createStateEvent
public static ItemStateEvent createStateEvent(String itemName, State state, @Nullable String source) Creates an item state event.- Parameters:
itemName
- the name of the item to send the state update forstate
- the new state to sendsource
- the name of the source identifying the sender (can be null)- Returns:
- the created item state event
- Throws:
IllegalArgumentException
- if itemName or state is null
-
createStateEvent
Creates an item state event.- Parameters:
itemName
- the name of the item to send the state update forstate
- the new state to send- Returns:
- the created item state event
- Throws:
IllegalArgumentException
- if itemName or state is null
-
createStateUpdatedEvent
Creates an item state updated event.- Parameters:
itemName
- the name of the item to report the state update forstate
- the new state- Returns:
- the created item state update event
- Throws:
IllegalArgumentException
- if itemName or state is null
-
createStateUpdatedEvent
public static ItemStateUpdatedEvent createStateUpdatedEvent(String itemName, State state, @Nullable String source) Creates an item state updated event.- Parameters:
itemName
- the name of the item to report the state update forstate
- the new statesource
- the name of the source identifying the sender (can be null)- Returns:
- the created item state update event
- Throws:
IllegalArgumentException
- if itemName or state is null
-
createTimeSeriesEvent
public static ItemTimeSeriesEvent createTimeSeriesEvent(String itemName, TimeSeries timeSeries, @Nullable String source) -
createTimeSeriesUpdatedEvent
public static ItemTimeSeriesUpdatedEvent createTimeSeriesUpdatedEvent(String itemName, TimeSeries timeSeries, @Nullable String source) -
createGroupStateUpdatedEvent
public static GroupStateUpdatedEvent createGroupStateUpdatedEvent(String groupName, String member, State state, @Nullable String source) Creates a group item state updated event.- Parameters:
groupName
- the name of the group to report the state update formember
- the name of the item that updated the group statestate
- the new statesource
- the name of the source identifying the sender (can be null)- Returns:
- the created group item state update event
- Throws:
IllegalArgumentException
- if groupName or state is null
-
createStatePredictedEvent
public static ItemStatePredictedEvent createStatePredictedEvent(String itemName, State state, boolean isConfirmation) Creates an item state predicted event.- Parameters:
itemName
- the name of the item to send the state update forstate
- the predicted state to sendisConfirmation
- whether this is a confirmation of a previous state- Returns:
- the created item state predicted event
- Throws:
IllegalArgumentException
- if itemName or state is null
-
createStateChangedEvent
public static ItemStateChangedEvent createStateChangedEvent(String itemName, State newState, State oldState) Creates an item state changed event.- Parameters:
itemName
- the name of the item to send the state changed event fornewState
- the new state to sendoldState
- the old state of the item- Returns:
- the created item state changed event
- Throws:
IllegalArgumentException
- if itemName or state is null
-
createGroupStateChangedEvent
public static GroupItemStateChangedEvent createGroupStateChangedEvent(String itemName, String memberName, State newState, State oldState) Creates a group item state changed event.- Parameters:
itemName
- the name of the group item to send the state changed event formemberName
- the name of the member causing the group item state changenewState
- the new state to sendoldState
- the old state of the group item- Returns:
- the created group item state changed event
- Throws:
IllegalArgumentException
- if itemName or state is null
-
createAddedEvent
Creates an item added event.- Parameters:
item
- the item- Returns:
- the created item added event
- Throws:
IllegalArgumentException
- if item is null
-
createRemovedEvent
Creates an item removed event.- Parameters:
item
- the item- Returns:
- the created item removed event
- Throws:
IllegalArgumentException
- if item is null
-
createUpdateEvent
Creates an item updated event.- Parameters:
item
- the itemoldItem
- the old item- Returns:
- the created item updated event
- Throws:
IllegalArgumentException
- if item or oldItem is null
-