vertx/src/main/java/eu/internetofus/common/vertx/ModelResources.java
/**
   * Merge a source model with the target one.
   *
   * @param model   to merge.
   * @param context of the request.
   * @param success component to call if the model is valid.
   *
   * @param <T>     type of model to merge.
   * @param <I>     type of the model identifier.
   * @param <C>     type of validation context to use.
   */
Merge a source model with the target one.
@param model   to merge.
@param context of the request.
@param success component to call if the model is valid.

@param      type of model to merge.
@param      type of the model identifier.
@param      type of validation context to use.
Merge a source model with the target one . @param model to merge . @param context of the request . @param success component to call if the model is valid . @param type of model to merge . @param type of the model identifier . @param type of validation context to use .
static public <C extends ValidateContext<C>, T extends Model & Mergeable<T, C>, I> void merge(
      @NotNull final ModelContext<T, I, C> model, @NotNull final ServiceContext context,
      @NotNull final Runnable success) {
    model.target.merge(model.source, model.validateContext).onComplete(merge -> {
      if (merge.failed()) {
        final var cause = merge.cause();
        Logger.trace(cause, "The {} can not be merged with {}.\n{}", () -> model.source, () -> model.target,
            () -> context);
        ServiceResponseHandlers.responseFailedWith(context.resultHandler, Status.BAD_REQUEST, cause);
      } else {
        model.value = merge.result();
        if (model.target.equals(model.value)) {
          Logger.trace("Ignored merged model {}, because it is equals to the original.\n{}", () -> model.value,
              () -> context);
          ServiceResponseHandlers.responseOk(context.resultHandler, model.value);
        } else {
          success.run();
        }
      }
    });
  }
static public < C extends ValidateContext < C > , T extends Model & Mergeable < T , C > , I > void merge ( @ NotNull final ModelContext < T , I , C > model , @ NotNull final ServiceContext context , @ NotNull final Runnable success ) { model . target . merge ( model . source , model . validateContext ) . onComplete ( merge -> { if ( merge . failed ( ) ) { final var cause = merge . cause ( ) ; Logger . trace ( cause , "The {} can not be merged with {}.\n{}" , ( ) -> model . source , ( ) -> model . target , ( ) -> context ) ; ServiceResponseHandlers . responseFailedWith ( context . resultHandler , Status . BAD_REQUEST , cause ) ; } else { model . value = merge . result ( ) ; if ( model . target . equals ( model . value ) ) { Logger . trace ( "Ignored merged model {}, because it is equals to the original.\n{}" , ( ) -> model . value , ( ) -> context ) ; ServiceResponseHandlers . responseOk ( context . resultHandler , model . value ) ; } else { success . run ( ) ; } } } ) ; }
Merge a source model with the target one.
Merge a source model with the target one .