Class DefaultFieldValueGenerator


  • public class DefaultFieldValueGenerator
    extends java.lang.Object
    Fills the fields with default not-null values. If a field type is an interface a proxy returning default values for each method will be created. If it's an abstract class a new concrete implementation of that type will created and instantiated at run-time.

    There are two scenarios where a field-type cannot possibly be assigned.

    1. When a class contains a field of it's own type, which would lead to infinite recursion, null is assigned.
    2. When the field type is an abstract Java system class with no visible constructor (package-private) null is assigned.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T fillWithDefaultValues​(T object)  
      private static java.lang.Object instantiateFieldType​(java.lang.reflect.Field field)  
      private static boolean isClass​(java.lang.Class<?> fieldType)  
      private static java.lang.Class<?> substituteKnownProblemTypes​(java.lang.Class<?> fieldType)
      Substitute class types that are known to cause problems when generating them.
      • Methods inherited from class java.lang.Object

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

      • DefaultFieldValueGenerator

        public DefaultFieldValueGenerator()
    • Method Detail

      • fillWithDefaultValues

        public static <T> T fillWithDefaultValues​(T object)
      • instantiateFieldType

        private static java.lang.Object instantiateFieldType​(java.lang.reflect.Field field)
      • isClass

        private static boolean isClass​(java.lang.Class<?> fieldType)
      • substituteKnownProblemTypes

        private static java.lang.Class<?> substituteKnownProblemTypes​(java.lang.Class<?> fieldType)
        Substitute class types that are known to cause problems when generating them.
        Parameters:
        fieldType - the field type.
        Returns:
        A field-type substitute or the original class.