Class Mapper<S,​D>

  • Type Parameters:
    S - The source type
    D - The destination type

    public class Mapper<S,​D>
    extends Object
    This class defines a reusable mapper object to perform multiple mappings for the configured object types.
    Author:
    schuettec
    • Method Detail

      • map

        public D map​(S source)
        Performs the mapping from the source to destination type.
        Parameters:
        source - The source object to map to a new destination object.
        Returns:
        Returns a newly created destination object.
      • map

        public D map​(S source,
                     D destination)
        Performs the mapping from the source into a specified destination object while overwriting fields in the destination object if affected by the mapping configuration.
        Parameters:
        source - The source object to map to a new destination object.
        destination - The destination object to map into. Field affected by the mapping will be overwritten.
        Returns:
        Returns the specified destination object.
      • map

        public Collection<D> map​(Collection<? extends S> source)
        Performs the mapping for the specified Collection.
        Parameters:
        source - The source collection to map to a new collection of destination objects.
        Returns:
        Returns a newly created collection of destination objects. The type of the resulting collection is either List or Set depending on the specified type.
      • map

        public List<D> map​(List<? extends S> source)
        Performs the mapping for the specified List.
        Parameters:
        source - The source collection to map to a new collection of destination objects.
        Returns:
        Returns a newly created list of destination objects.
      • map

        public Set<D> map​(Set<? extends S> source)
        Performs the mapping for the specified Set.
        Parameters:
        source - The source collection to map to a new collection of destination objects.
        Returns:
        Returns a newly set list of destination objects.
      • map

        public List<D> map​(Iterable<? extends S> iterable)
        Performs the mapping for the elements provided by the specified Iterable .
        Parameters:
        iterable - The source iterable to be mapped to a new List of destination objects.
        Returns:
        Returns a newly set list of destination objects.
      • mapOptional

        public D mapOptional​(S source)
        Performs the mapping from the source to destination type if the source value is non-null. If the source value is null this method returns null.
        Parameters:
        source - The source object to map to a new destination object. May be null.
        Returns:
        Returns a newly created destination object or null if the input value is null.
      • mapOrDefault

        public D mapOrDefault​(S source,
                              D defaultValue)
        Performs the mapping from the source to destination type if the source value is non-null. If the source value is null this method returns the specified default value.
        Parameters:
        source - The source object to map to a new destination object. May be null.
        defaultValue - The default value to return if the input is null.
        Returns:
        Returns a newly created destination object or the default value if the input value is null.