Class EventHandlerProcessor

java.lang.Object
com.tnsai.events.handler.EventHandlerProcessor

public final class EventHandlerProcessor extends Object
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 Details

    • extractHandlers

      public static List<EventHandlerMetadata> extractHandlers(Class<?> clazz)
      Extracts all EventHandler metadata 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

      public static boolean hasEventHandlers(Class<?> clazz)
      Checks whether a class has any @EventHandler annotated 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.