Package org.openhab.core.events
Class AbstractEvent
java.lang.Object
org.openhab.core.events.AbstractEvent
- All Implemented Interfaces:
Event
- Direct Known Subclasses:
AbstractInboxEvent,AbstractItemChannelLinkRegistryEvent,AbstractItemRegistryEvent,AbstractRuleRegistryEvent,AbstractThingRegistryEvent,AddonEvent,ChannelDescriptionChangedEvent,ChannelTriggeredEvent,ConfigStatusInfoEvent,ExecutionEvent,FirmwareStatusInfoEvent,FirmwareUpdateProgressInfoEvent,FirmwareUpdateResultInfoEvent,ItemEvent,RuleStatusInfoEvent,StartlevelEvent,ThingStatusInfoChangedEvent,ThingStatusInfoEvent,TimerEvent
Abstract implementation of the
Event interface.- Author:
- Stefan Bußweiler - Initial contribution
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractEvent(String topic, String payload, @Nullable String source) Must be called in subclass constructor to create a new event. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildDelegatedSource(@Nullable String originalSource, String bundle) Utility method to build a delegated source string from an original source and a bundlestatic StringbuildDelegatedSource(@Nullable String originalSource, String bundle, @Nullable String actor) Utility method to build a delegated source string from an original source, a bundle and an optional actor.static StringbuildSource(String bundle, @Nullable String actor) Utility method to build a source string from a bundle and an optional actor.booleanGets the payload as a serialized string.@Nullable StringGets the name of the source identifying the sender.getTopic()Gets the topic of an event.inthashCode()
-
Field Details
-
ACTOR_SEPARATOR
- See Also:
-
DELEGATION_SEPARATOR
- See Also:
-
DELEGATION_ESCAPE
- See Also:
-
-
Constructor Details
-
AbstractEvent
Must be called in subclass constructor to create a new event.- Parameters:
topic- the topicpayload- the payloadsource- the source
-
-
Method Details
-
getTopic
Description copied from interface:EventGets the topic of an event. -
getPayload
Description copied from interface:EventGets the payload as a serialized string.- Specified by:
getPayloadin interfaceEvent- Returns:
- the serialized event
-
getSource
Description copied from interface:EventGets the name of the source identifying the sender. -
hashCode
public int hashCode() -
equals
-
buildSource
Utility method to build a source string from a bundle and an optional actor. Bundle names may not contain the actor separator. The actor, if present, will be replaced with `__` to disallow the delegation separator. Consequently, `__` will be doubled as an escape sequence.- Parameters:
bundle- the bundle (such as org.openhab.core.thing or org.openhab.binding.matter)actor- the actor- Returns:
- the final source string
-
buildDelegatedSource
Utility method to build a delegated source string from an original source and a bundle- Parameters:
originalSource- the original source (may be null)bundle- the bundle (such as org.openhab.core.thing or org.openhab.binding.matter)- Returns:
- the final source string
-
buildDelegatedSource
public static String buildDelegatedSource(@Nullable String originalSource, String bundle, @Nullable String actor) Utility method to build a delegated source string from an original source, a bundle and an optional actor.- Parameters:
originalSource- the original source (may be null)bundle- the bundle (such as org.openhab.core.thing or org.openhab.binding.matter)actor- the actor- Returns:
- the final source string
-