java.lang.Object
com.thebuzzmedia.exiftool.commons.reflection.ClassUtils

public final class ClassUtils extends Object
Static Class Utilities.
  • Method Details

    • lookupClass

      public static Class<?> lookupClass(String klass)
      Get given class if available on classpath, otherwise throw ClassUtils.ReflectionException.
      Parameters:
      klass - Class name.
      Returns:
      The class instance if available.
      Throws:
      ClassUtils.ReflectionException - If given class is not found in the classpath.
    • findStaticMethod

      public static MethodHandle findStaticMethod(Class<?> klass, String methodName, Class<?> returnType, Class<?>... parameterTypes)
      Find static method with given return type parameter types on given class.
      Parameters:
      klass - The class.
      methodName - The method name.
      returnType - The method return type.
      parameterTypes - Parameter types.
      Returns:
      The method.
      Throws:
      ClassUtils.ReflectionException - If given method does not exist.
      ClassUtils.ReflectionException - If given method is not accessible.
    • findMethod

      public static MethodHandle findMethod(Class<?> klass, String methodName, Class<?> returnType, Class<?>... parameterTypes)
      Find non static method with given return type parameter types on given class.
      Parameters:
      klass - The class.
      methodName - The method name.
      returnType - The method return type.
      parameterTypes - Parameter types.
      Returns:
      The method.
      Throws:
      ClassUtils.ReflectionException - If given method does not exist.
      ClassUtils.ReflectionException - If given method is not accessible.
    • invokeStatic

      public static Object invokeStatic(MethodHandle method, Object... args)
      Invoke given static method.
      Parameters:
      method - The method to invoke.
      args - Method parameters.
      Returns:
      The method result.
      Throws:
      ClassUtils.ReflectionException - If an error occurs while calling method.
    • invoke

      public static Object invoke(MethodHandle method, Object target, Object... args)
      Invoke given method.
      Parameters:
      method - The method to invoke.
      target - The target instance.
      args - Method parameters.
      Returns:
      The method result.
      Throws:
      ClassUtils.ReflectionException - If an error occurs while calling method.
    • isPresent

      public static boolean isPresent(String klass)
      Check if given class is available on classpath.
      Parameters:
      klass - Class name to check (FQN).
      Returns:
      True if class is available, false otherwise.