- java.lang.Object
-
- com.remondis.remap.Mapper<S,D>
-
- Type Parameters:
S- The source typeD- 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 Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MappingModel<S,D>getMappingModel()List<D>map(Iterable<? extends S> iterable)Performs the mapping for the elements provided by the specifiedIterable.Collection<D>map(Collection<? extends S> source)Performs the mapping for the specifiedCollection.List<D>map(List<? extends S> source)Performs the mapping for the specifiedList.Set<D>map(Set<? extends S> source)Performs the mapping for the specifiedSet.Dmap(S source)Performs the mapping from the source to destination type.Dmap(S source, D destination)Deprecated.This method is deprecated, because the map-into feature of ReMap is not correctly implemented and will be removed in future release.DmapOptional(S source)Performs the mapping from the source to destination type if the source value is non-null.DmapOrDefault(S source, D defaultValue)Performs the mapping from the source to destination type if the source value is non-null.StringtoString()
-
-
-
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
@Deprecated public D map(S source, D destination)
Deprecated.This method is deprecated, because the map-into feature of ReMap is not correctly implemented and will be removed in future release. The complexity of mapping collections in a object tree is beyond of what ReMap is currently able to deliver. For example: The problem with mapping sets into lists is that the result becomes unstable as soon as both collections do not contain the same number of elements. Furthermore, not every element of one collection can be uniquely assigned to an element of the other collection without having to make serious API changes.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 specifiedCollection.
-
map
public List<D> map(List<? extends S> source)
Performs the mapping for the specifiedList.- 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 specifiedSet.- 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 specifiedIterable.- Parameters:
iterable- The source iterable to be mapped to a newListof 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 isnullthis method returnsnull.- Parameters:
source- The source object to map to a new destination object. May benull.- Returns:
- Returns a newly created destination object or
nullif the input value isnull.
-
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 isnullthis method returns the specified default value.- Parameters:
source- The source object to map to a new destination object. May benull.defaultValue- The default value to return if the input isnull.- Returns:
- Returns a newly created destination object or the default value if the input value is
null.
-
getMappingModel
public MappingModel<S,D> getMappingModel()
- Returns:
- Returns the
MappingModelfor this mapping.
-
-