Package ovh.mythmc.gestalt.annotations
Class FeatureListenerProcessor
java.lang.Object
ovh.mythmc.gestalt.annotations.FeatureListenerProcessor
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 Summary
ConstructorsConstructorDescriptionFeatureListenerProcessor(@NotNull Gestalt gestalt) Constructs a newFeatureListenerProcessorfor the givenGestaltinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcall(@NotNull Object instance, @Nullable Class<?> eventClass, @NotNull FeatureEvent event) Invokes allFeatureListener-annotated methods on the given instance that are listening to the specified feature class and event.getListeners(@NotNull Class<?> clazz) Returns all feature classes that any method in the given class listens to.getMethodListeners(@NotNull Method method) Returns the list of feature classes that the given method listens to, based on itsFeatureListenerannotation.booleanhasListeners(@NotNull Class<?> clazz) Returns whether the given class has anyFeatureListener-annotated methods.
-
Constructor Details
-
FeatureListenerProcessor
Constructs a newFeatureListenerProcessorfor the givenGestaltinstance.- Parameters:
gestalt- the active Gestalt instance
-
-
Method Details
-
getMethodListeners
Returns the list of feature classes that the given method listens to, based on itsFeatureListenerannotation.If a specific
FeatureListener.feature()class is defined (other than the defaultFeature), it takes priority. Otherwise, features are resolved byFeatureListener.group()andFeatureListener.identifier().- Parameters:
method- the method to inspect- Returns:
- a list of feature classes the method listens to
-
getListeners
Returns all feature classes that any method in the given class listens to.- Parameters:
clazz- the class to inspect forFeatureListener-annotated methods- Returns:
- a list of all feature classes listened to by methods in the class
-
hasListeners
Returns whether the given class has anyFeatureListener-annotated methods.- Parameters:
clazz- the class to check- Returns:
trueif 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 allFeatureListener-annotated methods on the given instance that are listening to the specified feature class and event.- Parameters:
instance- the listener object to call methods oneventClass- the feature class that triggered the event, ornullevent- the lifecycle event that was fired
-