vertx/src/main/java/eu/internetofus/common/vertx/ModelResources.java
/**
   * Update a source model with the target one.
   *
   * @param model     context of the model to update.
   * @param context   of the request.
   * @param nonEquals is {@code true} if the model can not be equals to the
   *                  original.
   * @param success   component to call if the model is valid.
   *
   * @param <T>       type of model to update.
   * @param <I>       type of the model identifier.
   * @param <C>       type of validation context to use.
   */
Update a source model with the target one.
@param model     context of the model to update.
@param context   of the request.
@param nonEquals is  true if the model can not be equals to the
original.
@param success   component to call if the model is valid.

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