Interface BeanTransformer

All Superinterfaces:
Transformer<BeanTransformer>
All Known Implementing Classes:
TransformerImpl

public interface BeanTransformer
extends Transformer<BeanTransformer>
Utility methods for populating Mutable, Immutable and Hybrid JavaBeans properties via reflection. The implementations are provided by TransformerImpl.
  • Method Details

    • transform

      <T,​ K> K transform​(T sourceObj, Class<? extends K> targetClass)
      Copies all properties from an object to a new one.
      Type Parameters:
      T - the Source object type
      K - the target object type
      Parameters:
      sourceObj - the source object
      targetClass - the destination object class
      Returns:
      a copy of the source object into the destination object
      Throws:
      IllegalArgumentException - if any parameter is invalid
    • transform

      <T,​ K> void transform​(T sourceObj, K targetObject)
      Copies all properties from an object to a new one.
      Type Parameters:
      T - the Source object type
      K - the target object type
      Parameters:
      sourceObj - the source object
      targetObject - the destination object
      Throws:
      IllegalArgumentException - if any parameter is invalid
    • setDefaultValueForMissingField

      BeanTransformer setDefaultValueForMissingField​(boolean useDefaultValue)
      It allows to configure the transformer in order to set a default value in case some field is missing in the source object. If set to true the default value is set, if false if it raises a: MissingFieldException in case of missing fields.
      Parameters:
      useDefaultValue - true in case the default value should be set, false if it should raise a: MissingFieldException in case of missing field.
      Returns:
      the BeanTransformer instance
    • setDefaultValueForMissingPrimitiveField

      BeanTransformer setDefaultValueForMissingPrimitiveField​(boolean useDefaultValue)
      It allows to enable/disable the set of the default value for primitive types in case they are null.
      Parameters:
      useDefaultValue - if true the default value for the primitive type is set. By default it's true.
      Returns:
      the BeanTransformer instance
    • setFlatFieldNameTransformation

      BeanTransformer setFlatFieldNameTransformation​(boolean useFlatTransformation)
      It allows to configure the transformer in order to apply a transformation function on all fields matching the given name without keeping in consideration their full path. If set to true the default value is set, if false if it raises a: MissingFieldException in case of missing fields.
      Parameters:
      useFlatTransformation - indicates if the transformer function has to be performed on all fields matching the given name without keeping in consideration their full path.
      Returns:
      the BeanTransformer instance
    • setValidationEnabled

      BeanTransformer setValidationEnabled​(boolean validationEnabled)
      It allows to enable the object validation.
      Parameters:
      validationEnabled - if true the validation is performed.
      Returns:
      the BeanTransformer instance
    • skipTransformationForField

      BeanTransformer skipTransformationForField​(String... fieldName)
      Allows to specify all the fields for which the transformation have to be skipped.
      Parameters:
      fieldName - the destination object's field(s) name that have to be skipped
      Returns:
      the BeanTransformer instance
    • resetFieldsTransformationSkip

      void resetFieldsTransformationSkip()
      Removes all the configured fields to skip.
    • setPrimitiveTypeConversionEnabled

      BeanTransformer setPrimitiveTypeConversionEnabled​(boolean primitiveTypeConversionEnabled)
      It allows to enable/disable the automatic conversion of primitive types.
      Parameters:
      primitiveTypeConversionEnabled - if true primitive types are transformed automatically. By default it's false.
      Returns:
      the BeanTransformer instance
    • setCustomBuilderTransformationEnabled

      BeanTransformer setCustomBuilderTransformationEnabled​(boolean customBuilderEnabled)
      It allows to enable/disable the transformation of Java Bean with a custom Builder pattern.
      Parameters:
      customBuilderEnabled - if true Java Beans with a custom Builder pattern are transformed automatically. By default it's false.
      Returns:
      the BeanTransformer instance