io.vertx.json.schema

## Interface JsonSchema

-     public interface JsonSchema

  A Json-Schema holder.

  There are 2 kinds of Json-Schema's:

  - JSON Object based
  - Boolean based

  This is a common interface to handle all kinds of schemas.

  Author:
    Paulo Lopes

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.util.function.Predicate<Map.Entry<String,Object>>` | `EXCLUDE_ANNOTATION_ENTRIES` Predicate to filter out annotation keys.
    `static java.util.function.Predicate<String>` | `EXCLUDE_ANNOTATIONS` Predicate to filter out annotation keys.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `JsonSchema` | `annotate(String key, String value)` Annotates the schema.
    `boolean` | `containsKey(String key)` Checks if the given key is present in the schema object.
    `Set<String>` | `fieldNames()` Returns the field names on the underlying object.
    `<R> R` | `get(String key)` Get a type casted value by key.
    `<R> R` | `get(String key, R fallback)` Get a type casted value by key.
    `static JsonSchema` | `of(boolean bool)` Factory method to create a `JsonSchema` from a `Boolean`.
    `static JsonSchema` | `of(JsonObject json)` Factory method to create a `JsonSchema` from a `JsonObject`.
    `static JsonSchema` | `of(String id, JsonObject json)` Factory method to create a `JsonSchema` from a `JsonObject`.
    `JsonObject` | `resolve()` Deprecated. will be removed in Vert.x 5

- - ### Field Detail

    - #### EXCLUDE_ANNOTATIONS

          static final java.util.function.Predicate<String> EXCLUDE_ANNOTATIONS

      Predicate to filter out annotation keys.

    - #### EXCLUDE_ANNOTATION_ENTRIES

          static final java.util.function.Predicate<Map.Entry<String,Object>> EXCLUDE_ANNOTATION_ENTRIES

      Predicate to filter out annotation keys.

  - ### Method Detail

    - #### of

          static JsonSchema of(JsonObject json)

      Factory method to create a `JsonSchema` from a `JsonObject`.
      Parameters:
        `json` - a JSON Object.
      Returns:
        a wrapper for the input object.

    - #### of

          static JsonSchema of(String id,
                               JsonObject json)

      Factory method to create a `JsonSchema` from a `JsonObject`.
      Parameters:
        `id` - will force the given id as the schema $id.
        `json` - a JSON Object.
      Returns:
        a wrapper for the input object.

    - #### of

          static JsonSchema of(boolean bool)

      Factory method to create a `JsonSchema` from a `Boolean`.
      Parameters:
        `bool` - a boolean.
      Returns:
        a wrapper for the input object.

    - #### annotate

          JsonSchema annotate(String key,
                              String value)

      Annotates the schema. An annotation is a extra key-value added to the schema that are not relevant for validation but can be used to store pre-computed state.
      Parameters:
        `key` - a key
        `value` - a value

    - #### get

          <R> R get(String key)

      Get a type casted value by key.
      Parameters:
        `key` - a key
      Returns:
        the value or `null`

    - #### get

          <R> R get(String key,
                    R fallback)

      Get a type casted value by key. If the key is missing, then the fallback value is returned.
      Parameters:
        `key` - a key
        `fallback` - fallback when key is not present
      Returns:
        the value or `null`

    - #### containsKey

          boolean containsKey(String key)

      Checks if the given key is present in the schema object.
      Parameters:
        `key` - a key
      Returns:
        `true` if present

    - #### fieldNames

          Set<String> fieldNames()

      Returns the field names on the underlying object.
      Returns:
        field names

    - #### resolve

          JsonObject resolve()

      Deprecated. will be removed in Vert.x 5
      Tries to resolve all internal references. External references are not resolved.

      The result is an object where all references have been resolved. Resolution of circular references is shallow. This should normally not be a problem for this use case.

      Returns:
        a new `JsonObject` representing the schema with `$ref`s replaced by their value.
      Throws:
        `SchemaException` - when the resolution is impossible.

Copyright © 2024 Eclipse. All rights reserved.