Package io.vertx.json.schema
Interface JsonSchema
-
public interface JsonSchemaA 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 Description static Predicate<Map.Entry<String,Object>>EXCLUDE_ANNOTATION_ENTRIESPredicate to filter out annotation keys.static Predicate<String>EXCLUDE_ANNOTATIONSPredicate to filter out annotation keys.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description JsonSchemaannotate(String key, String value)Annotates the schema.booleancontainsKey(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> Rget(String key)Get a type casted value by key.<R> Rget(String key, R fallback)Get a type casted value by key.static JsonSchemaof(boolean bool)Factory method to create aJsonSchemafrom aBoolean.static JsonSchemaof(JsonObject json)Factory method to create aJsonSchemafrom aJsonObject.static JsonSchemaof(String id, JsonObject json)Factory method to create aJsonSchemafrom aJsonObject.
-
-
-
Method Detail
-
of
static JsonSchema of(JsonObject json)
Factory method to create aJsonSchemafrom aJsonObject.- Parameters:
json- a JSON Object.- Returns:
- a wrapper for the input object.
-
of
static JsonSchema of(String id, JsonObject json)
Factory method to create aJsonSchemafrom aJsonObject.- 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 aJsonSchemafrom aBoolean.- 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 keyvalue- 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 keyfallback- 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:
trueif present
-
-