Class ReflectUtil


  • public abstract class ReflectUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ReflectUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.ClassLoader getClassLoader()  
      static java.lang.reflect.Field getField​(java.lang.String fieldName, java.lang.Class<?> clazz)
      Returns the field of the given class or null if it doesn't exist.
      static java.lang.reflect.Field getField​(java.lang.String fieldName, java.lang.Object object)
      Returns the field of the given object or null if it doesn't exist.
      static java.lang.String getGetterShorthandName​(java.lang.reflect.Method method)  
      static java.net.URL getResource​(java.lang.String name)  
      static java.io.InputStream getResourceAsStream​(java.lang.String name)  
      static java.lang.reflect.Method getSetter​(java.lang.String fieldName, java.lang.Class<?> clazz, java.lang.Class<?> fieldType)
      Returns the setter-method for the given field name or null if no setter exists.
      static java.lang.String getSetterShorthandName​(java.lang.reflect.Method method)  
      static java.lang.Object instantiate​(java.lang.String className)  
      static java.lang.Object instantiate​(java.lang.String className, java.lang.Object[] args)  
      static java.lang.Object invoke​(java.lang.Object target, java.lang.String methodName, java.lang.Object[] args)  
      static boolean isGetter​(java.lang.reflect.Method method)  
      static boolean isSetter​(java.lang.reflect.Method method)  
      static boolean isSetter​(java.lang.reflect.Method method, boolean allowBuilderPattern)  
      static java.lang.Class<?> loadClass​(java.lang.String className)  
      static void setField​(java.lang.reflect.Field field, java.lang.Object object, java.lang.Object value)  
      • Methods inherited from class java.lang.Object

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

      • ReflectUtil

        public ReflectUtil()
    • Method Detail

      • getClassLoader

        public static java.lang.ClassLoader getClassLoader()
      • loadClass

        public static java.lang.Class<?> loadClass​(java.lang.String className)
      • getResourceAsStream

        public static java.io.InputStream getResourceAsStream​(java.lang.String name)
      • getResource

        public static java.net.URL getResource​(java.lang.String name)
      • instantiate

        public static java.lang.Object instantiate​(java.lang.String className)
      • invoke

        public static java.lang.Object invoke​(java.lang.Object target,
                                              java.lang.String methodName,
                                              java.lang.Object[] args)
      • getField

        public static java.lang.reflect.Field getField​(java.lang.String fieldName,
                                                       java.lang.Object object)
        Returns the field of the given object or null if it doesn't exist.
      • getField

        public static java.lang.reflect.Field getField​(java.lang.String fieldName,
                                                       java.lang.Class<?> clazz)
        Returns the field of the given class or null if it doesn't exist.
      • setField

        public static void setField​(java.lang.reflect.Field field,
                                    java.lang.Object object,
                                    java.lang.Object value)
      • getSetter

        public static java.lang.reflect.Method getSetter​(java.lang.String fieldName,
                                                         java.lang.Class<?> clazz,
                                                         java.lang.Class<?> fieldType)
        Returns the setter-method for the given field name or null if no setter exists.
      • instantiate

        public static java.lang.Object instantiate​(java.lang.String className,
                                                   java.lang.Object[] args)
      • isGetter

        public static boolean isGetter​(java.lang.reflect.Method method)
      • isSetter

        public static boolean isSetter​(java.lang.reflect.Method method,
                                       boolean allowBuilderPattern)
      • isSetter

        public static boolean isSetter​(java.lang.reflect.Method method)
      • getGetterShorthandName

        public static java.lang.String getGetterShorthandName​(java.lang.reflect.Method method)
      • getSetterShorthandName

        public static java.lang.String getSetterShorthandName​(java.lang.reflect.Method method)