Enum Class ReflectionHelper

java.lang.Object
java.lang.Enum<ReflectionHelper>
com.github.thought2code.mcp.annotated.util.ReflectionHelper
All Implemented Interfaces:
Serializable, Comparable<ReflectionHelper>, Constable

public enum ReflectionHelper extends Enum<ReflectionHelper>
Helper class for reflection operations.

This class provides static methods for caching and invoking methods.

Author:
codeboyzhou
  • Enum Constant Details

    • INSTANCE

      public static final ReflectionHelper INSTANCE
      The singleton instance of the ReflectionHelper enum.
  • Method Details

    • values

      public static ReflectionHelper[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ReflectionHelper valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getOrCache

      public MethodCache getOrCache(Method method)
      Get or cache the metadata for the specified method.
      Parameters:
      method - the method to cache
      Returns:
      the cached method metadata
    • invoke

      public InvocationResult invoke(Object instance, MethodCache methodCache, List<Object> params)
      Invoke the method represented by the specified method cache on the given instance with the provided parameters.
      Parameters:
      instance - the instance on which to invoke the method
      methodCache - the method cache containing the method metadata
      params - the list of parameters to pass to the method
      Returns:
      the result of the method invocation
    • invoke

      public InvocationResult invoke(Object instance, MethodCache methodCache)
      Invoke the method represented by the specified method cache on the given instance with no parameters.
      Parameters:
      instance - the instance on which to invoke the method
      methodCache - the method cache containing the method metadata
      Returns:
      the result of the method invocation
    • invoke

      public InvocationResult invoke(Object instance, MethodCache methodCache, io.modelcontextprotocol.spec.McpSchema.CompleteRequest.CompleteArgument argument)
      Invoke the method represented by the specified method cache on the given instance with the provided argument.
      Parameters:
      instance - the instance on which to invoke the method
      methodCache - the method cache containing the method metadata
      argument - the argument to pass to the method
      Returns:
      the result of the method invocation