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

@NonNullByDefault public abstract class AbstractEvent extends Object implements Event
Abstract implementation of the Event interface.
Author:
Stefan Bußweiler - Initial contribution
  • Field Details

  • Constructor Details

    • AbstractEvent

      protected AbstractEvent(String topic, String payload, @Nullable String source)
      Must be called in subclass constructor to create a new event.
      Parameters:
      topic - the topic
      payload - the payload
      source - the source
  • Method Details

    • getTopic

      public String getTopic()
      Description copied from interface: Event
      Gets the topic of an event.
      Specified by:
      getTopic in interface Event
      Returns:
      the event topic
    • getPayload

      public String getPayload()
      Description copied from interface: Event
      Gets the payload as a serialized string.
      Specified by:
      getPayload in interface Event
      Returns:
      the serialized event
    • getSource

      public @Nullable String getSource()
      Description copied from interface: Event
      Gets the name of the source identifying the sender.
      Specified by:
      getSource in interface Event
      Returns:
      the name of the source
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • buildSource

      public static String buildSource(String packageName, @Nullable String actor)
      Utility method to build a source string from a package and an optional actor.
      Parameters:
      packageName - the package (such as org.openhab.core.thing or org.openhab.binding.matter)
      actor - the actor
      Returns:
      the final source string
    • buildDelegatedSource

      public static String buildDelegatedSource(@Nullable String originalSource, String packageName)
      Utility method to build a delegated source string from an original source and a package
      Parameters:
      originalSource - the original source (may be null)
      packageName - the package (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 packageName, @Nullable String actor)
      Utility method to build a delegated source string from an original source, a package and an optional actor.
      Parameters:
      originalSource - the original source (may be null)
      packageName - the package (such as org.openhab.core.thing or org.openhab.binding.matter)
      actor - the actor
      Returns:
      the final source string