Class AbstractExtension

java.lang.Object
com.mewna.catnip.extension.AbstractExtension
All Implemented Interfaces:
HasName, Extension

public abstract class AbstractExtension extends Object implements Extension
Since:
9/6/18
Author:
amy
  • Constructor Details

    • AbstractExtension

      public AbstractExtension(String name)
  • Method Details

    • registerHook

      public Extension registerHook(@Nonnull CatnipHook hook)
      Description copied from interface: Extension
      Register a hook into catnip. Hooks are registered by extension, so unloading an extension will also unload all of its hooks.
      Specified by:
      registerHook in interface Extension
      Parameters:
      hook - The hook to register.
      Returns:
      The extension instance.
    • unregisterHook

      public Extension unregisterHook(@Nonnull CatnipHook hook)
      Description copied from interface: Extension
      Unregister a hook from catnip.
      Specified by:
      unregisterHook in interface Extension
      Parameters:
      hook - The hook to unregister.
      Returns:
      The extension instance.
    • hooks

      public Set<CatnipHook> hooks()
      Specified by:
      hooks in interface Extension
      Returns:
      All hooks registered by this extension instance.
    • observable

      public <T> io.reactivex.rxjava3.core.Observable<T> observable(@Nonnull EventType<T> type)
      Description copied from interface: Extension
      Add a reactive stream handler for events of the given type. Can be disposed of with Observable.unsubscribeOn(Scheduler). The scheduler argument can be created with Catnip.rxScheduler().

      This method automatically subscribes on Catnip.rxScheduler().

      Specified by:
      observable in interface Extension
      Type Parameters:
      T - The object type of the event being streamed.
      Parameters:
      type - The type of event to stream.
      Returns:
      The observable.
    • flowable

      public <T> io.reactivex.rxjava3.core.Flowable<T> flowable(@Nonnull EventType<T> type)
      Description copied from interface: Extension
      Add a reactive stream handler for events of the given type. Can be disposed of with Flowable.unsubscribeOn(Scheduler). The scheduler argument can be created with Catnip.rxScheduler().

      This method automatically subscribes on Catnip.rxScheduler().

      Specified by:
      flowable in interface Extension
      Type Parameters:
      T - The object type of the event being streamed.
      Parameters:
      type - The type of event to stream.
      Returns:
      The flowable.
    • observable

      public <T, E> io.reactivex.rxjava3.core.Observable<org.apache.commons.lang3.tuple.Pair<T,E>> observable(@Nonnull DoubleEventType<T,E> type)
      Description copied from interface: Extension
      Add a reactive stream handler for events of the given type. Can be disposed of with Observable.unsubscribeOn(Scheduler). The scheduler argument can be created with Catnip.rxScheduler().

      This method automatically subscribes on Catnip.rxScheduler().

      Specified by:
      observable in interface Extension
      Type Parameters:
      T - The object type of the event being streamed.
      E - The object type of the event being streamed.
      Parameters:
      type - The type of event to stream.
      Returns:
      The observable.
    • flowable

      public <T, E> io.reactivex.rxjava3.core.Flowable<org.apache.commons.lang3.tuple.Pair<T,E>> flowable(@Nonnull DoubleEventType<T,E> type)
      Description copied from interface: Extension
      Add a reactive stream handler for events of the given type. Can be disposed of with Flowable.unsubscribeOn(Scheduler). The scheduler argument can be created with Catnip.rxScheduler().

      This method automatically subscribes on Catnip.rxScheduler().

      Specified by:
      flowable in interface Extension
      Type Parameters:
      T - The object type of the event being streamed.
      E - The object type of the event being streamed.
      Parameters:
      type - The type of event to stream.
      Returns:
      The flowable.
    • name

      public String name()
      Description copied from interface: Extension
      The name of this extension. Note that an extension's name is NOT guaranteed unique, and so your code should NOT rely on this for uniqueness!
      Specified by:
      name in interface Extension
      Specified by:
      name in interface HasName
      Returns:
      The name of this extension.
    • listeners

      public Set<MessageConsumer<?>> listeners()
      Specified by:
      listeners in interface Extension
      Returns:
      All listeners registered by this extension instance. Used for things like automatic unregistration of listeners on shutdown.
    • catnip

      public Catnip catnip()
      Description copied from interface: Extension
      The catnip instance this extension is registered to. This will not be null, as a proper extension manager implementation should inject the current catnip instance BEFORE deploying the extension.
      Specified by:
      catnip in interface Extension
      Returns:
      The catnip instance this extension is registered to.
    • catnip

      public AbstractExtension catnip(Catnip catnip)
      Description copied from interface: Extension
      Inject a catnip instance into this extension. This should be the same as the catnip version that is deploying this extension, and must not be null. A proper extension manager implementation will call this method to inject a catnip instance BEFORE deploying the extension, ie. Extension.onLoaded() will be called AFTER this method.
      Specified by:
      catnip in interface Extension
      Parameters:
      catnip - The catnip instance to inject. May not be null.
      Returns:
      this.