vertx/src/main/java/eu/internetofus/common/vertx/ModelResources.java
/**
   * Return the model described in a JSON.
   *
   * @param value   of the model to verify.
   * @param model   context of the model to obtain.
   * @param context of the request.
   * @param success component to call when has obtained the model.
   *
   * @param <T>     type of model to obtain form the JSON.
   * @param <I>     type for the model identifier.
   * @param <C>     type of validation context to use.
   */
Return the model described in a JSON.
@param value   of the model to verify.
@param model   context of the model to obtain.
@param context of the request.
@param success component to call when has obtained the model.

@param      type of model to obtain form the JSON.
@param      type for the model identifier.
@param      type of validation context to use.
Return the model described in a JSON . @param value of the model to verify . @param model context of the model to obtain . @param context of the request . @param success component to call when has obtained the model . @param type of model to obtain form the JSON . @param type for the model identifier . @param type of validation context to use .
static public <T extends Model, I, C extends ValidateContext<C>> void toModel(final JsonObject value,
      @NotNull final ModelContext<T, I, C> model, @NotNull final ServiceContext context,
      @NotNull final Runnable success) {
    if (value == null) {
      Logger.trace("The NULL JSON does not represents a {}.\n{}", () -> model, () -> context);
      ServiceResponseHandlers.responseWithErrorMessage(context.resultHandler, Status.BAD_REQUEST, "bad_" + model.name,
          "No JSON provided for a " + model.name + ".");
    } else {
      Model.fromFutureJsonObject(Future.succeededFuture(value), model.type).onComplete(parsed -> {
        if (parsed.failed()) {
          final var cause = parsed.cause();
          Logger.trace(cause, "The JSON does not represents a {}.\n{}\n{}", () -> model, () -> value.encodePrettily(),
              () -> context);
          ServiceResponseHandlers.responseWithErrorMessage(context.resultHandler, Status.BAD_REQUEST,
              "bad_" + model.name, "The JSON does not represents a " + model.name + ", because "
                  + cause.getMessage().replaceAll("\\([^\\(]*\\w(\\.\\w)*[^\\(]*\\)", ""));
        } else {
          model.source = parsed.result();
          Logger.trace("Obtain model {}.\n{}", model, context);
          success.run();
        }
      });
    }
  }
static public < T extends Model , I , C extends ValidateContext < C > > void toModel ( final JsonObject value , @ NotNull final ModelContext < T , I , C > model , @ NotNull final ServiceContext context , @ NotNull final Runnable success ) { if ( value == null ) { Logger . trace ( "The NULL JSON does not represents a {}.\n{}" , ( ) -> model , ( ) -> context ) ; ServiceResponseHandlers . responseWithErrorMessage ( context . resultHandler , Status . BAD_REQUEST , "bad_" + model . name , "No JSON provided for a " + model . name + "." ) ; } else { Model . fromFutureJsonObject ( Future . succeededFuture ( value ) , model . type ) . onComplete ( parsed -> { if ( parsed . failed ( ) ) { final var cause = parsed . cause ( ) ; Logger . trace ( cause , "The JSON does not represents a {}.\n{}\n{}" , ( ) -> model , ( ) -> value . encodePrettily ( ) , ( ) -> context ) ; ServiceResponseHandlers . responseWithErrorMessage ( context . resultHandler , Status . BAD_REQUEST , "bad_" + model . name , "The JSON does not represents a " + model . name + ", because " + cause . getMessage ( ) . replaceAll ( "\\([^\\(]*\\w(\\.\\w)*[^\\(]*\\)" , "" ) ) ; } else { model . source = parsed . result ( ) ; Logger . trace ( "Obtain model {}.\n{}" , model , context ) ; success . run ( ) ; } } ) ; } }
Return the model described in a JSON.
Return the model described in a JSON .