java.lang.Object
java.util.AbstractMap<Object,Object>
java.util.HashMap<Object,Object>
berlin.yuna.typemap.model.TypeMap
org.nanonative.nano.helper.event.model.Event
All Implemented Interfaces:
berlin.yuna.typemap.model.TypeInfo<berlin.yuna.typemap.model.TypeMap>, berlin.yuna.typemap.model.TypeMapI<berlin.yuna.typemap.model.TypeMap>, Serializable, Cloneable, Map<Object,Object>

public class Event extends berlin.yuna.typemap.model.TypeMap
See Also:
  • Field Details

    • channelId

      protected int channelId
    • context

      protected final Context context
    • responseListener

      protected transient Consumer<Object> responseListener
    • payload

      protected transient Supplier<Object> payload
    • payloadRaw

      protected transient Object payloadRaw
    • response

      protected transient Object response
    • error

      protected Throwable error
    • EVENT_ORIGINAL_CHANNEL_ID

      public static final String EVENT_ORIGINAL_CHANNEL_ID
      See Also:
  • Constructor Details

    • Event

      public Event(Context context)
      Constructs an instance of the Event class with specified type, context, payload, and response listener. This event object can be used to trigger specific actions or responses based on the event type and payload.
      Parameters:
      context - The Context in which the event is created and processed. It provides environmental data and configurations.
  • Method Details

    • eventOf

      public static Event eventOf(Context context, int channelId)
    • asyncEventOf

      public static Event asyncEventOf(Context context, int channelId)
    • channel

      public String channel()
      Returns the event name based on the channel ID.
      Returns:
      The name of the event.
    • nameOrg

      public String nameOrg()
      Returns the event name based on the original channel ID.
      Returns:
      The name of the event.
    • nano

      public Nano nano()
    • channelId

      public int channelId()
      Returns:
      The integer representing the type of the event. This typically corresponds to a specific kind of event.
    • channelIdOrg

      public int channelIdOrg()
      Returns:
      The integer representing the original type of the event. This typically corresponds to a specific kind of event.
    • channelId

      public Event channelId(int channelId)
      Sets the channel ID of the event.
      Parameters:
      channelId - The integer representing the type of the event. This typically corresponds to a specific kind of event.
      Returns:
      self for chaining
    • async

      public Event async(boolean async)
      Sets the event to asynchronous mode, allowing the response to be handled by a listener.
      Returns:
      self for chaining
    • async

      public Event async(Consumer<Object> responseListener)
      Sets the event to asynchronous mode, allowing the response to be handled by a listener.
      Parameters:
      responseListener - A consumer that handles the response of the event processing. It can be used to execute actions based on the event's outcome or data.
      Returns:
      self for chaining
    • payload

      public Event payload(Supplier<Object> payload)
      Sets the payload of the event.
      Parameters:
      payload - The data or object that is associated with this event. This can be any relevant information that needs to be passed along with the event.
      Returns:
      self for chaining
    • ifPresent

      public Event ifPresent(int channelId, Consumer<Event> consumer)
    • ifPresentAck

      public Event ifPresentAck(int channelId, Consumer<Event> consumer)
    • ifPresent

      public <T> Event ifPresent(int channelId, Class<T> clazz, Consumer<T> consumer)
    • ifPresentAck

      public <T> Event ifPresentAck(int channelId, Class<T> clazz, Function<T,Object> consumer)
    • payload

      public Object payload()
    • isBroadcast

      public boolean isBroadcast()
    • broadcast

      public Event broadcast(boolean broadcast)
    • isAcknowledged

      public boolean isAcknowledged()
    • payloadOpt

      public Optional<Object> payloadOpt()
    • payload

      public <T> T payload(Class<T> type)
    • payloadOpt

      public <T> Optional<T> payloadOpt(Class<T> type)
    • context

      public Context context()
    • isAsync

      public boolean isAsync()
    • async

      public Consumer<Object> async()
    • acknowledge

      public Event acknowledge()
    • acknowledge

      public Event acknowledge(Runnable response)
    • response

      public Event response(Object response)
    • response

      public <T> T response(Class<T> type)
    • responseOpt

      public <T> Optional<T> responseOpt(Class<T> type)
    • response

      public Object response()
    • peek

      public Event peek(Consumer<Event> peek)
    • putR

      public Event putR(Object key, Object value)
    • filter

      public berlin.yuna.typemap.model.Type<Event> filter(Predicate<Event> predicate)
    • error

      public Throwable error()
    • error

      public Event error(Throwable error)
    • send

      public Event send()
      Sends the event to the Nano instance for processing.
      Returns:
      self for chaining
    • toString

      public String toString()
      Overrides:
      toString in class AbstractMap<Object,Object>
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Map<Object,Object>
      Overrides:
      equals in class AbstractMap<Object,Object>
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<Object,Object>
      Overrides:
      hashCode in class AbstractMap<Object,Object>