Package ovh.mythmc.gestalt.util
Class MethodUtil
java.lang.Object
ovh.mythmc.gestalt.util.MethodUtil
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 Summary
Modifier and TypeMethodDescriptionstatic ObjectReflectively invokes the given method on the cached instance of the specified feature class.static voidtriggerAnnotatedMethod(@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.
-
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 instanceclazz- the feature class whose annotated methods should be invokedannotation- 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 instanceclazz- the feature class to get or create an instance ofmethod- the method to invoke- Returns:
- the return value of the method, or
nullif the invocation failed
-