Class ServiceMediator

java.lang.Object
com.github.philippheuer.events4j.core.services.ServiceMediator
All Implemented Interfaces:
com.github.philippheuer.events4j.api.service.IServiceMediator

public final class ServiceMediator extends Object implements com.github.philippheuer.events4j.api.service.IServiceMediator
The ServiceMediator

The ServiceMediator provides access to 3rd party services for your custom events

  • Constructor Summary

    Constructors
    Constructor
    Description
    ServiceMediator(com.github.philippheuer.events4j.api.IEventManager eventManager)
    The Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addService(@NonNull String serviceName, @NonNull Object serviceInstance)
    Add a service to the ServiceMediator.
    com.github.philippheuer.events4j.api.IEventManager
    Holds a reference of the EventManager
    <T> @NonNull T
    getService(@NonNull Class<T> serviceClass, @NonNull String serviceName)
    Gets a service from the ServiceMediator

    Methods inherited from class java.lang.Object

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

    • ServiceMediator

      public ServiceMediator(com.github.philippheuer.events4j.api.IEventManager eventManager)
      The Constructor.
      Parameters:
      eventManager - The EventManager
  • Method Details

    • addService

      public void addService(@NonNull String serviceName, @NonNull Object serviceInstance)
      Add a service to the ServiceMediator.
      Specified by:
      addService in interface com.github.philippheuer.events4j.api.service.IServiceMediator
      Parameters:
      serviceName - The ServiceName
      serviceInstance - The ServiceInstance
    • getService

      public <T> @NonNull T getService(@NonNull Class<T> serviceClass, @NonNull String serviceName)
      Gets a service from the ServiceMediator
      Specified by:
      getService in interface com.github.philippheuer.events4j.api.service.IServiceMediator
      Type Parameters:
      T - The type of the Service
      Parameters:
      serviceClass - The ServiceClass you expect
      serviceName - The ServiceName
      Returns:
      The ServiceInstance
    • getEventManager

      public com.github.philippheuer.events4j.api.IEventManager getEventManager()
      Holds a reference of the EventManager