Class 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 Detail

      • withPropertyPath

        public <E extends ExceptionMappingConfiguration<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) and Map.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 null value. If a get call in the chain returns a null value, 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 MappingConfiguration for further mapping configuration.
      • withPropertyPathAnd

        public <X,​E extends ExceptionPropertyPathAndApplyCollectionBuilder<S,​D,​RD,​X,​RS,​E> withPropertyPathAnd​(com.remondis.propertypath.api.PropertyPath<X,​RS,​E> propertyPath)
        Works exactly like withPropertyPath(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 returns null the 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 PropertyPathAndApplyBuilder to 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 for null itself. Use withSkipWhenNull(Function) to skip on null items.
        Parameters:
        transformation - The transform function.
        Returns:
        Returns the MappingConfiguration for 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 not null. This method skips the execution of the transform function if the source value is null.
        Parameters:
        transformation - The transform function.
        Returns:
        Returns the MappingConfiguration for further mapping configuration.