Class FeatureListenerProcessor

java.lang.Object
ovh.mythmc.gestalt.annotations.FeatureListenerProcessor

public final class FeatureListenerProcessor extends Object
Processes FeatureListener annotations and dispatches feature lifecycle events to the appropriate listener methods.

This processor is responsible for resolving which feature classes a method listens to and for invoking listener methods when a FeatureEvent is fired.

  • Constructor Details

    • FeatureListenerProcessor

      public FeatureListenerProcessor(@NotNull @NotNull Gestalt gestalt)
      Constructs a new FeatureListenerProcessor for the given Gestalt instance.
      Parameters:
      gestalt - the active Gestalt instance
  • Method Details

    • getMethodListeners

      public ArrayList<Class<?>> getMethodListeners(@NotNull @NotNull Method method)
      Returns the list of feature classes that the given method listens to, based on its FeatureListener annotation.

      If a specific FeatureListener.feature() class is defined (other than the default Feature), it takes priority. Otherwise, features are resolved by FeatureListener.group() and FeatureListener.identifier().

      Parameters:
      method - the method to inspect
      Returns:
      a list of feature classes the method listens to
    • getListeners

      public ArrayList<Class<?>> getListeners(@NotNull @NotNull Class<?> clazz)
      Returns all feature classes that any method in the given class listens to.
      Parameters:
      clazz - the class to inspect for FeatureListener-annotated methods
      Returns:
      a list of all feature classes listened to by methods in the class
    • hasListeners

      public boolean hasListeners(@NotNull @NotNull Class<?> clazz)
      Returns whether the given class has any FeatureListener-annotated methods.
      Parameters:
      clazz - the class to check
      Returns:
      true if the class has at least one listener method
    • call

      public void call(@NotNull @NotNull Object instance, @Nullable @Nullable Class<?> eventClass, @NotNull @NotNull FeatureEvent event)
      Invokes all FeatureListener-annotated methods on the given instance that are listening to the specified feature class and event.
      Parameters:
      instance - the listener object to call methods on
      eventClass - the feature class that triggered the event, or null
      event - the lifecycle event that was fired