public abstract class Schema extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Schema.Builder<S extends Schema>
Abstract builder class for the builder classes of
Schema subclasses. |
Modifier and Type | Field and Description |
---|---|
protected String |
schemaLocation
Deprecated.
|
Modifier | Constructor and Description |
---|---|
protected |
Schema(Schema.Builder<?> builder)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
canEqual(Object other)
Since we add state in subclasses, but want those subclasses to be non final, this allows us to
have equals methods that satisfy the equals contract.
|
boolean |
definesProperty(String field)
Determines if this
Schema instance defines any restrictions for the object property
denoted by field . |
void |
describeTo(JSONPrinter writer)
Describes the instance as a JSONObject to
writer . |
boolean |
equals(Object o) |
protected ValidationException |
failure(Class<?> expectedType,
Object actualValue)
Deprecated.
|
protected ValidationException |
failure(String message,
String keyword)
Deprecated.
|
Object |
getDefaultValue() |
String |
getDescription() |
String |
getId() |
SchemaLocation |
getLocation() |
String |
getSchemaLocation() |
String |
getTitle() |
Map<String,Object> |
getUnprocessedProperties()
Returns the properties of the original schema JSON which aren't keywords of json schema
(therefore they weren't recognized during schema loading).
|
boolean |
hasDefaultValue() |
int |
hashCode() |
Boolean |
isNullable() |
Boolean |
isReadOnly() |
Boolean |
isWriteOnly() |
String |
toString() |
void |
validate(Object subject)
Performs the schema validation.
|
@Deprecated protected final String schemaLocation
protected Schema(Schema.Builder<?> builder)
builder
- the builder containing the optional title, description and id attributes of the schemapublic void validate(Object subject)
subject
- the object to be validatedValidationException
- if the subject
is invalid against this schema.public boolean definesProperty(String field)
Schema
instance defines any restrictions for the object property
denoted by field
. The field
should be a JSON pointer, denoting the property to
be queried.
For example the field "#/rectangle/a"
is defined by the following schema:
objectWithSchemaRectangleDep" : {
"type" : "object",
"dependencies" : {
"d" : {
"type" : "object",
"properties" : {
"rectangle" : {"$ref" : "#/definitions/Rectangle" }
}
}
},
"definitions" : {
"size" : {
"type" : "number",
"minimum" : 0
},
"Rectangle" : {
"type" : "object",
"properties" : {
"a" : {"$ref" : "#/definitions/size"},
"b" : {"$ref" : "#/definitions/size"}
}
}
}
}
The default implementation of this method always returns false.field
- should be a JSON pointer in its string representation.true
if the propertty denoted by field
is defined by this schema
instancepublic String getTitle()
public String getDescription()
public String getId()
public String getSchemaLocation()
public SchemaLocation getLocation()
public Object getDefaultValue()
public boolean hasDefaultValue()
public Boolean isNullable()
public Boolean isReadOnly()
public Boolean isWriteOnly()
public Map<String,Object> getUnprocessedProperties()
public void describeTo(JSONPrinter writer)
writer
.
First it adds the "title
, "description"
and "id"
properties then calls
describePropertiesTo(JSONPrinter)
, which will add the subclass-specific properties.
It is used by toString()
to serialize the schema instance into its JSON representation.
writer
- it will receive the schema description@Deprecated protected ValidationException failure(String message, String keyword)
@Deprecated protected ValidationException failure(Class<?> expectedType, Object actualValue)
protected boolean canEqual(Object other)
http://www.artima.com/lejava/articles/equality.html
other
- the subject of comparisontrue
if this
can be equal to other
Copyright © 2019 Everit Kft.. All rights reserved.