model/src/main/java/eu/internetofus/common/model/Merges.java
/**
   * Merge a field that is mergeable too.
   *
   * @param context   to use.
   * @param fieldName name of the field to merge.
   * @param target    field value to merge.
   * @param source    field value to merge.
   * @param setter    function to set the merged field into the merged model.
   *
   * @param <M>       type of merging model.
   * @param <T>       type of the field.
   * @param <C>       type of validation context to use.
   *
   * @return the future that will provide the merged lists.
   */
Merge a field that is mergeable too.
@param context   to use.
@param fieldName name of the field to merge.
@param target    field value to merge.
@param source    field value to merge.
@param setter    function to set the merged field into the merged model.

@param        type of merging model.
@param        type of the field.
@param        type of validation context to use.

@return the future that will provide the merged lists.
Merge a field that is mergeable too . @param context to use . @param fieldName name of the field to merge . @param target field value to merge . @param source field value to merge . @param setter function to set the merged field into the merged model . @param type of merging model . @param type of the field . @param type of validation context to use . @return the future that will provide the merged lists .
static <C extends ValidateContext<C>, M, T extends Mergeable<T, C>> Function<M, Future<M>> mergeField(final C context,
      final String fieldName, final T target, final T source, final BiConsumer<M, T> setter) {
    return merged -> {
      if (target != null) {
        final var fieldContext = context.createFieldContext(fieldName);
        return target.merge(source, fieldContext).map(mergedField -> {
          setter.accept(merged, mergedField);
          return merged;
        });
      } else {
        if (source != null) {
          setter.accept(merged, source);
        }
        return Future.succeededFuture(merged);
      }
    };
  }
static < C extends ValidateContext < C > , M , T extends Mergeable < T , C > > Function < M , Future < M > > mergeField ( final C context , final String fieldName , final T target , final T source , final BiConsumer < M , T > setter ) { return merged -> { if ( target != null ) { final var fieldContext = context . createFieldContext ( fieldName ) ; return target . merge ( source , fieldContext ) . map ( mergedField -> { setter . accept ( merged , mergedField ) ; return merged ; } ) ; } else { if ( source != null ) { setter . accept ( merged , source ) ; } return Future . succeededFuture ( merged ) ; } } ; }
Merge a field that is mergeable too.
Merge a field that is mergeable too .