- java.lang.Object
-
- com.remondis.remap.PropertyPathTransformation<RS,X,RD>
-
- Type Parameters:
RS- The type of the source field.X- Tje type of the value returned by a property path.RD- The type of the destination field.
public class PropertyPathTransformation<RS,X,RD> extends Object
The property path operation maps the result of a property path that is applied to the source field to another field. If the property path does not return a value, the mapping is omitted.- Author:
- schuettec
-
-
Field Summary
Fields Modifier and Type Field Description protected PropertyDescriptordestinationPropertyprotected MappingConfiguration<?,?>mappingprotected PropertyDescriptorsourceProperty
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)StringgetDestinationPropertyName()protected Class<?>getDestinationType()StringgetSourcePropertyName()protected Class<?>getSourceType()inthashCode()<S,T>
booleanhasMapperFor(Class<S> sourceType, Class<T> destinationType)Checks if the specified mapper is registered.protected voidperformTransformation(PropertyDescriptor sourceProperty, Object source, PropertyDescriptor destinationProperty, Object destination)Performs a single transformation step while mapping.voidperformTransformation(Object source, Object destination)Performs the transformation for the specified source and destination.protected MappedResultperformValueTransformation(Object source, Object destination)Performs a single value transformation.protected ObjectreadOrFail(PropertyDescriptor property, Object source)StringtoString()StringtoString(boolean detailed)protected voidvalidateTransformation()Lets this transformation validate its configuration.protected voidwriteOrFail(PropertyDescriptor property, Object source, Object value)
-
-
-
Field Detail
-
sourceProperty
protected PropertyDescriptor sourceProperty
-
destinationProperty
protected PropertyDescriptor destinationProperty
-
mapping
protected MappingConfiguration<?,?> mapping
-
-
Method Detail
-
getSourcePropertyName
public String getSourcePropertyName()
- Returns:
- Returns the source property name. This might be a property path, if the transformation operates on property paths like PropertyPathTransformation.
-
performTransformation
protected void performTransformation(PropertyDescriptor sourceProperty, Object source, PropertyDescriptor destinationProperty, Object destination) throws MappingException
Performs a single transformation step while mapping. In contrast to#performValueTransformation(PropertyDescriptor, Object, PropertyDescriptor, Object)this method should implement field access to read/write mapping values. This method should delegate to#performValueTransformation(PropertyDescriptor, Object, PropertyDescriptor, Object)to perform the actual value mapping.- Parameters:
sourceProperty- The source propertysource- The source object to map from.destinationProperty- The destination propertydestination- The destination object to map to.- Throws:
MappingException- Thrown on any mapping exception.
-
performValueTransformation
protected MappedResult performValueTransformation(Object source, Object destination) throws MappingException
Performs a single value transformation. This method is used to provide single field mappings viaMappingModel, therefore this method should work without side-effects like accessing fields to read or write mapping values.- Parameters:
source- The source object to map from.destination- The destination object to map to.- Returns:
- Returns a
MappedResultspecifying the mapping value or signals to skip the mapping, because the transformation does not produce a destination value. - Throws:
MappingException- Thrown on any mapping exception.
-
validateTransformation
protected void validateTransformation() throws MappingExceptionLets this transformation validate its configuration. If the state of this transformation is invalid, implementations may throw aMappingException.- Throws:
MappingException- Thrown if the transformation setup is invalid
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
toString
public String toString(boolean detailed)
-
getDestinationPropertyName
public String getDestinationPropertyName()
- Returns:
- Returns the destination property name.
-
getDestinationType
protected Class<?> getDestinationType()
-
getSourceType
protected Class<?> getSourceType()
-
readOrFail
protected Object readOrFail(PropertyDescriptor property, Object source)
-
writeOrFail
protected void writeOrFail(PropertyDescriptor property, Object source, Object value)
-
performTransformation
public void performTransformation(Object source, Object destination) throws MappingException
Performs the transformation for the specified source and destination.- Parameters:
source- The source objectdestination- The destination object.- Throws:
MappingException- Thrown on any transformation error.
-
hasMapperFor
public <S,T> boolean hasMapperFor(Class<S> sourceType, Class<T> destinationType)
Checks if the specified mapper is registered.- Parameters:
sourceType- The source typedestinationType- the destination type- Returns:
- Returns
trueif a mapper was registered for this type of conversion. Otherwisefalseis returned.
-
-