Class ReflectionHelper


  • public final class ReflectionHelper
    extends java.lang.Object
    A utility/helper class for working with Classes and Reflection.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ReflectionHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.lang.reflect.Constructor<T> getConstructor​(java.lang.Class<T> instantiable, java.lang.Class<?>... constructorParameterTypes)  
      static boolean hasDefaultConstructor​(java.lang.Class<?> aClass)  
      static <T> T newInstance​(java.lang.Class<T> aClass)
      This method may return null if the call to create a newInstance() fails.
      static <T> T newInstance​(java.lang.reflect.Constructor<T> constructor, java.lang.Object... constructorArguments)  
      static boolean parameterTypesMatch​(java.lang.Class<?>[] candidateParamTypes, java.lang.Class<?>... desiredParameterTypes)  
      private static <T> java.lang.reflect.Constructor<T> searchForConstructor​(java.lang.Class<T> instantiable, java.lang.Class<?>... constructorParameterTypes)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMPTY_CLASS_ARRAY

        @Deprecated
        public static final java.lang.Class[] EMPTY_CLASS_ARRAY
        Deprecated.
        in 2.0. Will become private in a future version.
      • WRAPPER_TO_PRIMATIVES

        private static final ImmutableMap<java.lang.Class<?>,​java.lang.Class<?>> WRAPPER_TO_PRIMATIVES
        Mapping of iterator wrapper classes to iterator types
      • PRIMATIVES_TO_WRAPPERS

        private static final ImmutableMap<java.lang.Class<?>,​java.lang.Class<?>> PRIMATIVES_TO_WRAPPERS
    • Constructor Detail

      • ReflectionHelper

        private ReflectionHelper()
    • Method Detail

      • getConstructor

        public static <T> java.lang.reflect.Constructor<T> getConstructor​(java.lang.Class<T> instantiable,
                                                                          java.lang.Class<?>... constructorParameterTypes)
      • searchForConstructor

        private static <T> java.lang.reflect.Constructor<T> searchForConstructor​(java.lang.Class<T> instantiable,
                                                                                 java.lang.Class<?>... constructorParameterTypes)
      • parameterTypesMatch

        public static boolean parameterTypesMatch​(java.lang.Class<?>[] candidateParamTypes,
                                                  java.lang.Class<?>... desiredParameterTypes)
      • newInstance

        public static <T> T newInstance​(java.lang.reflect.Constructor<T> constructor,
                                        java.lang.Object... constructorArguments)
      • newInstance

        public static <T> T newInstance​(java.lang.Class<T> aClass)
        This method may return null if the call to create a newInstance() fails.
      • hasDefaultConstructor

        public static boolean hasDefaultConstructor​(java.lang.Class<?> aClass)