Class MethodUtil

java.lang.Object
ovh.mythmc.gestalt.util.MethodUtil

public class MethodUtil extends Object
Utility class for reflectively invoking methods on feature class instances.

Manages a cache of instantiated feature objects (keyed by class name) to avoid repeated instantiation. Constructor parameters, if required, are looked up via the FeatureConstructorParamsRegistry.

  • Method Details

    • triggerAnnotatedMethod

      public static void triggerAnnotatedMethod(@NotNull @NotNull Gestalt gestalt, Class<?> clazz, Class<? extends Annotation> annotation)
      Invokes all methods on the given feature class that are annotated with the specified lifecycle annotation.
      Parameters:
      gestalt - the active Gestalt instance, used to retrieve the singleton feature instance
      clazz - the feature class whose annotated methods should be invoked
      annotation - the lifecycle annotation to match (e.g., FeatureEnable)
    • invoke

      public static Object invoke(@NotNull @NotNull Gestalt gestalt, @NotNull @NotNull Class<?> clazz, @NotNull @NotNull Method method)
      Reflectively invokes the given method on the cached instance of the specified feature class.

      Instantiates the feature class on first call using its registered constructor parameters or a no-arg constructor if none are provided.

      Parameters:
      gestalt - the active Gestalt instance
      clazz - the feature class to get or create an instance of
      method - the method to invoke
      Returns:
      the return value of the method, or null if the invocation failed