Class FieldTransformer<T,​K>

  • Type Parameters:
    T - input field type.
    K - field value on with apply the function.

    public class FieldTransformer<T,​K>
    extends Object
    Specifies the field mapping between the source object and destination one.
    • Constructor Detail

      • FieldTransformer

        public FieldTransformer​(String destinationFieldName,
                                Function<T,​K> fieldTransformerFunction)
        Creates a field transformer with a lambda function to be applied on the field.
        Parameters:
        destinationFieldName - the field name in the destination object.
        fieldTransformerFunction - the transformer function to apply on field
      • FieldTransformer

        public FieldTransformer​(String destinationFieldName,
                                Supplier<K> fieldTransformerSupplier)
        Creates a field transformer with a field supplier function to be applied on the field.
        Parameters:
        destinationFieldName - the field name in the destination object.
        fieldTransformerSupplier - the transformer supplier to apply on field
    • Method Detail

      • getTransformedObject

        public final K getTransformedObject​(T objectToTransform)
        Returns a transformed object by applying the defined transformed function or the supplier.
        Parameters:
        objectToTransform - the object to transform
        Returns:
        the transformed object
        Throws:
        InvalidFunctionException - if the defined function cannot be applied to the given type