Class ReflectionUtils


  • public class ReflectionUtils
    extends Object
    • Constructor Detail

      • ReflectionUtils

        public ReflectionUtils()
    • Method Detail

      • getStaticFields

        public static HashMap<Class<?>,​List<Field>> getStaticFields​(List<Class<?>> classes)
        Parameters:
        classes - List of classes
        Returns:
        A mapping of classes to their corresponding static fields
      • getStaticFields

        public static List<Field> getStaticFields​(Class<?> clazz)
        Parameters:
        clazz - The class from which the static fields should be obtained
        Returns:
        The list of static fields from that class
      • getStaticField

        public static Object getStaticField​(Class<?> clazz,
                                            String fieldName)
        Parameters:
        clazz - The class from which the static field should be obtained
        fieldName - The name of the field that should be obtained
        Returns:
        The value of the field
      • getField

        public static Field getField​(Object obj,
                                     String fieldName)
        Parameters:
        obj - The object whose field should be accessed
        fieldName - The name of the field which should be accessed
        Returns:
        The requested Field
      • getFieldValue

        public static Object getFieldValue​(Object obj,
                                           String fieldName)
        Parameters:
        obj - The object whose property value should be accessed
        fieldName - The name of the field which should be accessed
        Returns:
        The requested field value or null if not found