Class BasicAppEvent

java.lang.Object
net.solarnetwork.event.BasicAppEvent
All Implemented Interfaces:
AppEvent

public class BasicAppEvent extends Object implements AppEvent
Basic immutable AppEvent.
Since:
2.0
Version:
1.0
Author:
matt
  • Constructor Details

    • BasicAppEvent

      public BasicAppEvent(String topic, Map<String,?> eventProperties)
      Constructor.

      The event creation date will be set to the current time.

      Parameters:
      topic - the event topic
      eventProperties - the event properties, or null
      Throws:
      IllegalArgumentException - if topic is null
    • BasicAppEvent

      public BasicAppEvent(String topic, Instant created, Map<String,?> eventProperties)
      Constructor.
      Parameters:
      topic - the event topic
      created - the event creation date, or null to use the current time
      eventProperties - the event properties, or null
      Throws:
      IllegalArgumentException - if topic is null or empty
  • Method Details

    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static BasicAppEvent.Builder builder()
      Creates builder to build BasicAppEvent.
      Returns:
      created builder
    • getTopic

      public String getTopic()
      Description copied from interface: AppEvent
      Get the event topic.

      By convention topics are path-like structures like datum/agg/calculated.

      Specified by:
      getTopic in interface AppEvent
      Returns:
      the event topic, never null
    • getCreated

      public Instant getCreated()
      Description copied from interface: AppEvent
      Get the date the event was created.
      Specified by:
      getCreated in interface AppEvent
      Returns:
      the creation date, never null
    • getEventProperties

      public Map<String,?> getEventProperties()
      Description copied from interface: AppEvent
      Get the properties of the event.

      The available properties is topic-specific.

      Specified by:
      getEventProperties in interface AppEvent
      Returns:
      the event properties, never null
    • toBuilder

      public BasicAppEvent.Builder toBuilder()
      Get a builder, populated with this instance's values.
      Returns:
      a pre-populated builder