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
FieldsModifier and TypeFieldDescriptionPredicate to filter out annotation keys.Predicate to filter out annotation keys. -
Method Summary
Modifier and TypeMethodDescriptionAnnotates the schema.booleancontainsKey(String key) Checks if the given key is present in the schema object.Returns the field names on the underlying object.<R> RGet a type casted value by key.<R> RGet 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.
-
Field Details
-
EXCLUDE_ANNOTATIONS
-
EXCLUDE_ANNOTATION_ENTRIES
-
-
Method Details
-
of
Factory method to create aJsonSchemafrom aJsonObject.- Parameters:
json- a JSON Object.- Returns:
- a wrapper for the input object.
-
of
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
Factory method to create aJsonSchemafrom aBoolean.- Parameters:
bool- a boolean.- Returns:
- a wrapper for the input object.
-
annotate
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
Get a type casted value by key.- Parameters:
key- a key- Returns:
- the value or
null
-
get
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
Checks if the given key is present in the schema object.- Parameters:
key- a key- Returns:
trueif present
-
fieldNames
-