Class 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
    • 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 property
        source - The source object to map from.
        destinationProperty - The destination property
        destination - 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 via MappingModel, 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 MappedResult specifying 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 MappingException
        Lets this transformation validate its configuration. If the state of this transformation is invalid, implementations may throw a MappingException.
        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()
      • performTransformation

        public void performTransformation​(Object source,
                                          Object destination)
                                   throws MappingException
        Performs the transformation for the specified source and destination.
        Parameters:
        source - The source object
        destination - 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 type
        destinationType - the destination type
        Returns:
        Returns true if a mapper was registered for this type of conversion. Otherwise false is returned.