Package org.everit.json.schema
Class ArraySchema
- java.lang.Object
-
- org.everit.json.schema.Schema
-
- org.everit.json.schema.ArraySchema
-
public class ArraySchema extends Schema
Array schema validator.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classArraySchema.BuilderBuilder class forArraySchema.
-
Field Summary
-
Fields inherited from class org.everit.json.schema.Schema
schemaLocation
-
-
Constructor Summary
Constructors Constructor Description ArraySchema(ArraySchema.Builder builder)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ArraySchema.Builderbuilder()protected booleancanEqual(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.booleandefinesProperty(String field)Determines if thisSchemainstance defines any restrictions for the object property denoted byfield.booleanequals(Object o)SchemagetAllItemSchema()SchemagetContainedItemSchema()List<Schema>getItemSchemas()IntegergetMaxItems()IntegergetMinItems()SchemagetSchemaOfAdditionalItems()inthashCode()booleanneedsUniqueItems()booleanpermitsAdditionalItems()booleanrequiresArray()-
Methods inherited from class org.everit.json.schema.Schema
describeTo, failure, failure, getDefaultValue, getDescription, getId, getLocation, getSchemaLocation, getTitle, getUnprocessedProperties, hasDefaultValue, isNullable, isReadOnly, isWriteOnly, toString, validate
-
-
-
-
Constructor Detail
-
ArraySchema
public ArraySchema(ArraySchema.Builder builder)
Constructor.- Parameters:
builder- contains validation criteria.
-
-
Method Detail
-
builder
public static ArraySchema.Builder builder()
-
getAllItemSchema
public Schema getAllItemSchema()
-
getMaxItems
public Integer getMaxItems()
-
getMinItems
public Integer getMinItems()
-
getSchemaOfAdditionalItems
public Schema getSchemaOfAdditionalItems()
-
getContainedItemSchema
public Schema getContainedItemSchema()
-
needsUniqueItems
public boolean needsUniqueItems()
-
permitsAdditionalItems
public boolean permitsAdditionalItems()
-
requiresArray
public boolean requiresArray()
-
definesProperty
public boolean definesProperty(String field)
Description copied from class:SchemaDetermines if thisSchemainstance defines any restrictions for the object property denoted byfield. Thefieldshould be a JSON pointer, denoting the property to be queried.For example the field
"#/rectangle/a"is defined by the following schema:
You can also check if a subschema of an array defines a property. In that case, to traverse the array, you can either use an integer array index, or theobjectWithSchemaRectangleDep" : { "type" : "object", "dependencies" : { "d" : { "type" : "object", "properties" : { "rectangle" : { "$ref" : "#/definitions/Rectangle" }, "list": { "type": "array", "items": { "properties": { "prop": {} } }, "minItems": 2, "maxItems: 3 } } } }, "definitions" : { "size" : { "type" : "number", "minimum" : 0 }, "Rectangle" : { "type" : "object", "properties" : { "a" : {"$ref" : "#/definitions/size"}, "b" : {"$ref" : "#/definitions/size"} } } } }"all"or"any"meta-indexes. For example, in the above schemadefinesProperty("#/list/any/prop")returnstruedefinesProperty("#/list/all/prop")returnstruedefinesProperty("#/list/1/prop")returnstruedefinesProperty("#/list/1/nonexistent")returnsfalse(the property is not present in the subschema)definesProperty("#/list/8/prop")returnsfalse(the"list"does not define property8, since"maxItems"is3)
- Overrides:
definesPropertyin classSchema- Parameters:
field- should be a JSON pointer in its string representation.- Returns:
trueif the propertty denoted byfieldis defined by this schema instance
-
canEqual
protected boolean canEqual(Object other)
Description copied from class:SchemaSince 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.http://www.artima.com/lejava/articles/equality.html
-
-