Class FieldExtractor


  • public class FieldExtractor
    extends Object

    Class for extracting fields of class

    Since:
    1.0
    Author:
    Christoph Praschl
    • Constructor Detail

      • FieldExtractor

        public FieldExtractor()
    • Method Detail

      • getAllFieldsForClass

        public static List<Field> getAllFieldsForClass​(Class<?> clazz)
      • getClassField

        public static Field getClassField​(Class<?> clazz,
                                          String fieldName)
        Method for getting a field by name and given class
        Parameters:
        clazz - Class which contains the field
        fieldName - Name of the Field
        Returns:
        the field
        Throws:
        IllegalArgumentException - if there is no field with given name
      • getDefaultValueForField

        public static <T> T getDefaultValueForField​(Field field)
        Get default value of given clazz
        Type Parameters:
        T - type of clazz
        Parameters:
        field - field to be checked if there is a user defined default value
        Returns:
        default value of field; if no user defined value was set returns default value of clazz
      • getDefaultValueForClass

        public static <T> T getDefaultValueForClass​(Class<T> clazz)
        Get default value of given clazz
        Type Parameters:
        T - type of clazz
        Parameters:
        clazz - clazz for which default value should be get
        Returns:
        default value of clazz