Class FieldTransformer<T,​K>

java.lang.Object
com.expediagroup.transformer.model.FieldTransformer<T,​K>
Type Parameters:
T - input field type.
K - field value on with apply the function.

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

    Constructors
    Constructor Description
    FieldTransformer​(java.lang.String destinationFieldName, java.util.function.Function<T,​K> fieldTransformerFunction)
    Creates a field transformer with a lambda function to be applied on the field.
    FieldTransformer​(java.lang.String destinationFieldName, java.util.function.Supplier<K> fieldTransformerSupplier)
    Creates a field transformer with a field supplier function to be applied on the field.
    FieldTransformer​(java.util.List<java.lang.String> destinationFieldNames, java.util.function.Function<T,​K> fieldTransformerFunction)
    Creates a field transformer with a lambda function to be applied on a list of fields.
  • Method Summary

    Modifier and Type Method Description
    K getTransformedObject​(T objectToTransform)
    Returns a transformed object by applying the defined transformed function or the supplier.

    Methods inherited from class java.lang.Object

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

    • FieldTransformer

      public FieldTransformer​(java.util.List<java.lang.String> destinationFieldNames, java.util.function.Function<T,​K> fieldTransformerFunction)
      Creates a field transformer with a lambda function to be applied on a list of fields.
      Parameters:
      destinationFieldNames - the field name in the destination object.
      fieldTransformerFunction - the transformer function to apply on field
    • FieldTransformer

      public FieldTransformer​(java.lang.String destinationFieldName, java.util.function.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​(java.lang.String destinationFieldName, java.util.function.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 Details

    • 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