components/src/test/java/eu/internetofus/common/components/GetSetContext.java
/**
   * Create a handler to retrieve a value.
   *
   * @param prefix       to apply to the identifier.
   * @param defaultValue to return if is not defined or {@code null} to fail if
   *                     not found.
   * @param params       name of the path elements with the identifiers.
   *
   * @return the handler to get a value.
   */
Create a handler to retrieve a value.
@param prefix       to apply to the identifier.
@param defaultValue to return if is not defined or  null to fail if
not found.
@param params       name of the path elements with the identifiers.

@return the handler to get a value.
Create a handler to retrieve a value . @param prefix to apply to the identifier . @param defaultValue to return if is not defined or null to fail if not found . @param params name of the path elements with the identifiers . @return the handler to get a value .
public Handler<RoutingContext> createGetHandler(final String prefix, final ClusterSerializable defaultValue,
      final String... params) {
    return ctx -> {
      final var id = this.getIdFrom(ctx, prefix, params);
      final var response = ctx.response();
      final var value = this.values.get(id);
      if (value != null) {
        response.setStatusCode(Status.OK.getStatusCode());
        response.end(this.toBuffer(value));
      } else if (defaultValue != null) {
        response.setStatusCode(Status.OK.getStatusCode());
        response.end(this.toBuffer(defaultValue));
      } else {
        response.setStatusCode(Status.NOT_FOUND.getStatusCode());
        response.end(new ErrorMessage("bad_id", "Does not exist any value associated to the identifier.").toBuffer());
      }
    };
  }
public Handler < RoutingContext > createGetHandler ( final String prefix , final ClusterSerializable defaultValue , final String ... params ) { return ctx -> { final var id = this . getIdFrom ( ctx , prefix , params ) ; final var response = ctx . response ( ) ; final var value = this . values . get ( id ) ; if ( value != null ) { response . setStatusCode ( Status . OK . getStatusCode ( ) ) ; response . end ( this . toBuffer ( value ) ) ; } else if ( defaultValue != null ) { response . setStatusCode ( Status . OK . getStatusCode ( ) ) ; response . end ( this . toBuffer ( defaultValue ) ) ; } else { response . setStatusCode ( Status . NOT_FOUND . getStatusCode ( ) ) ; response . end ( new ErrorMessage ( "bad_id" , "Does not exist any value associated to the identifier." ) . toBuffer ( ) ) ; } } ; }
Create a handler to retrieve a value.
Create a handler to retrieve a value .