- java.lang.Object
-
- com.remondis.remap.ReplaceCollectionBuilder<S,D,RD,RS>
-
- Type Parameters:
S- The source type.D- The destination type.RS- The source field type.RD- The destination field type.
public class ReplaceCollectionBuilder<S,D,RD,RS> extends Object
Builds a replace collection operation.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MappingConfiguration<S,D>with(Function<RS,RD> transformation)Transforms the items in the collection held by the selected field by applying the specified transform function on each item.<E extends Exception>
MappingConfiguration<S,D>withPropertyPath(com.remondis.propertypath.api.PropertyPath<RD,RS,E> propertyPath)Maps the items of the collections held by the source field by evaluating the specified property path.<X,E extends Exception>
PropertyPathAndApplyCollectionBuilder<S,D,RD,X,RS,E>withPropertyPathAnd(com.remondis.propertypath.api.PropertyPath<X,RS,E> propertyPath)Works exactly likewithPropertyPath(PropertyPath)but accepts a transformation function, that is to be specified on the returned builder.MappingConfiguration<S,D>withSkipWhenNull(Function<RS,RD> transformation)Transforms the items in the collection held by the selected field by applying the specified transform function on each item if the item is notnull.
-
-
-
Method Detail
-
withPropertyPath
public <E extends Exception> MappingConfiguration<S,D> withPropertyPath(com.remondis.propertypath.api.PropertyPath<RD,RS,E> propertyPath)
Maps the items of the collections held by the source field by evaluating the specified property path. A property path is useful for flattening objects and the easy handling of optional values in a Java Bean object graph. The mapping will only be performed if the property path evaluates to a non-null value. Otherwise the mapping will be skipped.What is a property path
A property path is a chain of get calls. Java Bean compliant get methods as well as
List.get(int)andMap.get(Object)are supported. The get call chain evaluation and the null checks between the get calls are performed by the framework to support optional fields while avoiding the need of implementing null checks. The property path only evaluates to a non-null value, if all get calls return a non-null value.The property path will be evaluated during the mapping and every get-call is checked for a
nullvalue. If a get call in the chain returns anullvalue, the whole evaluation returns no value. In this case the mapping will be skipped.- Parameters:
propertyPath- A lambda function performing get calls on the specified object to declare the actual property path. This is not a function operating on real object. So do not manipulate or calculate here!- Returns:
- Returns the
MappingConfigurationfor further mapping configuration.
-
withPropertyPathAnd
public <X,E extends Exception> PropertyPathAndApplyCollectionBuilder<S,D,RD,X,RS,E> withPropertyPathAnd(com.remondis.propertypath.api.PropertyPath<X,RS,E> propertyPath)
Works exactly likewithPropertyPath(PropertyPath)but accepts a transformation function, that is to be specified on the returned builder. The function will be applied to the result of the property path evaluation, but only if the property path evaluates to a non-null value. If the specified transform function itself returnsnullthe property path evaluates to no value.- Parameters:
propertyPath- A lambda function performing get calls on the specified object to declare the actual property path. This is not a function operating on real object. So do not manipulate or calculate here!- Returns:
- Returns the
PropertyPathAndApplyBuilderto specify the transformation function.
-
with
public MappingConfiguration<S,D> with(Function<RS,RD> transformation)
Transforms the items in the collection held by the selected field by applying the specified transform function on each item. Note: The transform function must check the value fornullitself. UsewithSkipWhenNull(Function)to skip onnullitems.- Parameters:
transformation- The transform function.- Returns:
- Returns the
MappingConfigurationfor further mapping configuration.
-
withSkipWhenNull
public MappingConfiguration<S,D> withSkipWhenNull(Function<RS,RD> transformation)
Transforms the items in the collection held by the selected field by applying the specified transform function on each item if the item is notnull. This method skips the execution of the transform function if the source value isnull.- Parameters:
transformation- The transform function.- Returns:
- Returns the
MappingConfigurationfor further mapping configuration.
-
-