Package com.hotels.transformer.model
Class FieldTransformer<T,K>
- java.lang.Object
-
- com.hotels.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 Object
Specifies the field mapping between the source object and destination one.
-
-
Constructor Summary
Constructors Constructor Description FieldTransformer(String destinationFieldName, Function<T,K> fieldTransformerFunction)
Creates a field transformer with a lambda function to be applied on the field.FieldTransformer(String destinationFieldName, Supplier<K> fieldTransformerSupplier)
Creates a field transformer with a field supplier function to be applied on the field.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description K
getTransformedObject(T objectToTransform)
Returns a transformed object by applying the defined transformed function or the supplier.
-
-
-
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
-
-