Package com.tnsai.events.handler
Class EventHandlerProcessor
java.lang.Object
com.tnsai.events.handler.EventHandlerProcessor
Extracts
EventHandler metadata from annotated classes.
Scans a class hierarchy for methods annotated with @EventHandler
and returns structured metadata for runtime registration.
Results are cached per class to avoid repeated reflection.
Usage
List<EventHandlerMetadata> handlers = EventHandlerProcessor.extractHandlers(MyRole.class);
handlers.forEach(h -> System.out.println(h.eventName() + " -> " + h.method().getName()));
- Author:
- TnsAI Team
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears the metadata cache.static List<EventHandlerMetadata> extractHandlers(Class<?> clazz) Extracts allEventHandlermetadata from the given class.static booleanhasEventHandlers(Class<?> clazz) Checks whether a class has any@EventHandlerannotated methods.
-
Method Details
-
extractHandlers
Extracts allEventHandlermetadata from the given class.Scans the class and its superclasses (up to Object) for annotated methods. Results are sorted by
EventHandler.order()and cached.- Parameters:
clazz- the class to scan- Returns:
- unmodifiable list of handler metadata, sorted by order
-
hasEventHandlers
Checks whether a class has any@EventHandlerannotated methods.- Parameters:
clazz- the class to check- Returns:
- true if at least one handler is found
-
clearCache
public static void clearCache()Clears the metadata cache.
-