Class Reflection

java.lang.Object
joptsimple.internal.Reflection

public final class Reflection extends Object
Helper methods for reflection.
  • Constructor Details

    • Reflection

      private Reflection()
  • Method Details

    • findConverter

      public static <V> ValueConverter<V> findConverter(Class<V> clazz)
      Finds an appropriate value converter for the given class.
      Type Parameters:
      V - a constraint on the class object to introspect
      Parameters:
      clazz - class to introspect on
      Returns:
      a converter method or constructor
    • valueOfConverter

      private static <V> ValueConverter<V> valueOfConverter(Class<V> clazz)
    • constructorConverter

      private static <V> ValueConverter<V> constructorConverter(Class<V> clazz)
    • instantiate

      public static <T> T instantiate(Constructor<T> constructor, Object... args)
      Invokes the given constructor with the given arguments.
      Type Parameters:
      T - constraint on the type of the objects yielded by the constructor
      Parameters:
      constructor - constructor to invoke
      args - arguments to hand to the constructor
      Returns:
      the result of invoking the constructor
      Throws:
      ReflectionException - in lieu of the gaggle of reflection-related exceptions
    • invoke

      public static Object invoke(Method method, Object... args)
      Invokes the given static method with the given arguments.
      Parameters:
      method - method to invoke
      args - arguments to hand to the method
      Returns:
      the result of invoking the method
      Throws:
      ReflectionException - in lieu of the gaggle of reflection-related exceptions
    • convertWith

      public static <V> V convertWith(ValueConverter<V> converter, String raw)
    • meetsConverterRequirements

      private static boolean meetsConverterRequirements(Method method, Class<?> expectedReturnType)
    • reflectionException

      private static RuntimeException reflectionException(Exception ex)