vertx/src/main/java/eu/internetofus/common/vertx/ModelResources.java
/**
   * Retrieve a field defined into a model.
   *
   * @param model    context of the model to retrieve.
   * @param searcher the function used to obtain a model from an identifier.
   * @param getField return the field value associated to a model.
   * @param context  of the request.
   *
   * @param <T>      type of model that contains the fields.
   * @param <E>      type of the field.
   * @param <I>      type of the identifier.
   * @param <C>      type of validation context to use.
   */
Retrieve a field defined into a model.
@param model    context of the model to retrieve.
@param searcher the function used to obtain a model from an identifier.
@param getField return the field value associated to a model.
@param context  of the request.

@param       type of model that contains the fields.
@param       type of the field.
@param       type of the identifier.
@param       type of validation context to use.
Retrieve a field defined into a model . @param model context of the model to retrieve . @param searcher the function used to obtain a model from an identifier . @param getField return the field value associated to a model . @param context of the request . @param type of model that contains the fields . @param type of the field . @param type of the identifier . @param type of validation context to use .
static public <T extends Model, E extends Model, I, C extends ValidateContext<C>> void retrieveModelField(
      @NotNull final ModelContext<T, I, C> model, @NotNull final BiConsumer<I, Handler<AsyncResult<T>>> searcher,
      @NotNull final Function<T, List<E>> getField, @NotNull final ServiceContext context) {
    retrieveModelChain(model, searcher, context, () -> {
      final var field = getField.apply(model.target);
      JsonArray array = null;
      if (field == null) {
        array = new JsonArray();
      } else {
        array = Model.toJsonArray(field);
      }
      Logger.trace("For {} retrieve {}.\n{}", model, field, context);
      ServiceResponseHandlers.responseOk(context.resultHandler, array);
    });
  }
static public < T extends Model , E extends Model , I , C extends ValidateContext < C > > void retrieveModelField ( @ NotNull final ModelContext < T , I , C > model , @ NotNull final BiConsumer < I , Handler < AsyncResult < T > > > searcher , @ NotNull final Function < T , List < E > > getField , @ NotNull final ServiceContext context ) { retrieveModelChain ( model , searcher , context , ( ) -> { final var field = getField . apply ( model . target ) ; JsonArray array = null ; if ( field == null ) { array = new JsonArray ( ) ; } else { array = Model . toJsonArray ( field ) ; } Logger . trace ( "For {} retrieve {}.\n{}" , model , field , context ) ; ServiceResponseHandlers . responseOk ( context . resultHandler , array ) ; } ) ; }
Retrieve a field defined into a model.
Retrieve a field defined into a model .