Class ReflectUtil

java.lang.Object
org.cryptacular.util.ReflectUtil

public final class ReflectUtil extends Object
Reflection utilities.
  • Field Details

    • METHOD_CACHE

      private static final Map<String,Method> METHOD_CACHE
      Method cache.
  • Constructor Details

    • ReflectUtil

      private ReflectUtil()
      Private constructor of utility class.
  • Method Details

    • getMethod

      public static Method getMethod(Class<?> target, String name, Class<?>... parameters)
      Gets the method defined on the target class. The method is cached to speed up subsequent lookups.
      Parameters:
      target - Target class that contains method.
      name - Method name.
      parameters - Method parameters.
      Returns:
      Method if found, otherwise null.
    • invoke

      public static Object invoke(Object target, Method method, Object... parameters)
      Invokes the method on the target object with the given parameters.
      Parameters:
      target - Target class that contains method.
      method - Method to invoke on target.
      parameters - Method parameters.
      Returns:
      Method return value. A void method returns null.