Interface JsonRpcParams


public interface JsonRpcParams
A representation of a JSON-RPC params.
  • Method Details

    • create

      static JsonRpcParams create(JsonStructure params)
      Create an instance from a JSON structure.
      Parameters:
      params - the structure
      Returns:
      a new instance of this class
    • asJsonObject

      JsonObject asJsonObject()
      Access all request params as a single JSON object.
      Returns:
      a JSON object
      Throws:
      ClassCastException - if not a JSON object
    • asJsonArray

      JsonArray asJsonArray()
      Access all request params as a single JSON array.
      Returns:
      a JSON array
      Throws:
      ClassCastException - if not a JSON array
    • asJsonStructure

      JsonStructure asJsonStructure()
      Access all request params as a single JSON structure.
      Returns:
      a JSON structure
    • get

      JsonValue get(String name)
      Get a single param by name as a JSON value.
      Parameters:
      name - param name
      Returns:
      the param value
      Throws:
      ClassCastException - if not a JSON object
      IllegalArgumentException - if the param does not exist
    • getString

      String getString(String name)
      Get a single param by name as a string.
      Parameters:
      name - param name
      Returns:
      the param value as a string
      Throws:
      ClassCastException - if not a JSON object or value not a string
      IllegalArgumentException - if the param does not exist
    • find

      Optional<JsonValue> find(String name)
      Get a single param by name as a JSON value, if present.
      Parameters:
      name - param name
      Returns:
      an optional param value
      Throws:
      ClassCastException - if not a JSON object
    • get

      JsonValue get(int index)
      Get a single array param by index as a JSON value.
      Parameters:
      index - the index
      Returns:
      the param value
      Throws:
      ClassCastException - if not a JSON array
      IndexOutOfBoundsException - if index is out of bounds
    • getString

      String getString(int index)
      Get a single array param by index as a string.
      Parameters:
      index - the index
      Returns:
      the param value as a string
      Throws:
      ClassCastException - if not a JSON array or value not a string
      IndexOutOfBoundsException - if index is out of bounds
    • find

      Optional<JsonValue> find(int index)
      Get a single array param by index as a JSON value, if present.
      Parameters:
      index - the index
      Returns:
      an optional param value
      Throws:
      ClassCastException - if not a JSON array
      IndexOutOfBoundsException - if index is out of bounds
    • as

      <T> T as(Class<T> type)
      Map all request params to a bean class type using JSONB.
      Type Parameters:
      T - the bean type
      Parameters:
      type - the bean class
      Returns:
      an instance of the bean type
      Throws:
      JsonbException - if an error occurs during mapping