Class SimpleEventHandler

java.lang.Object
com.github.philippheuer.events4j.simple.SimpleEventHandler
All Implemented Interfaces:
com.github.philippheuer.events4j.api.service.IEventHandler, java.lang.AutoCloseable

public class SimpleEventHandler
extends java.lang.Object
implements com.github.philippheuer.events4j.api.service.IEventHandler
  • Constructor Summary

    Constructors
    Constructor Description
    SimpleEventHandler()  
  • Method Summary

    Modifier and Type Method Description
    void close()
    Shutdown
    java.util.concurrent.ConcurrentMap<java.lang.Class<?>,​java.util.List<java.util.function.Consumer<java.lang.Object>>> getConsumerBasedHandlers()
    Consumer based handlers
    <E> com.github.philippheuer.events4j.api.domain.IDisposable onEvent​(java.lang.Class<E> eventClass, java.util.function.Consumer<E> consumer)
    Registers a new consumer based event handler
    void publish​(java.lang.Object event)
    Dispatched a event to the simple based method listeners.
    void registerListener​(java.lang.Object eventListener)
    Registers a listener using EventSubscriber method annotations.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SimpleEventHandler

      public SimpleEventHandler()
  • Method Details

    • registerListener

      public void registerListener​(java.lang.Object eventListener)
      Registers a listener using EventSubscriber method annotations.
      Parameters:
      eventListener - The class instance annotated with EventSubscriber annotations.
    • onEvent

      public <E> com.github.philippheuer.events4j.api.domain.IDisposable onEvent​(java.lang.Class<E> eventClass, java.util.function.Consumer<E> consumer)
      Registers a new consumer based event handler
      Specified by:
      onEvent in interface com.github.philippheuer.events4j.api.service.IEventHandler
      Type Parameters:
      E - the event type
      Parameters:
      eventClass - the event class to obtain events from
      consumer - the event consumer / handler method
      Returns:
      a new Disposable of the given eventType
    • publish

      public void publish​(java.lang.Object event)
      Dispatched a event to the simple based method listeners.
      Specified by:
      publish in interface com.github.philippheuer.events4j.api.service.IEventHandler
      Parameters:
      event - The event that will be dispatched to the simple based method listeners.
    • close

      public void close()
      Shutdown
      Specified by:
      close in interface java.lang.AutoCloseable
    • getConsumerBasedHandlers

      public java.util.concurrent.ConcurrentMap<java.lang.Class<?>,​java.util.List<java.util.function.Consumer<java.lang.Object>>> getConsumerBasedHandlers()
      Consumer based handlers