Class TypedJsonSchemaObject.ArrayJsonSchemaObject
java.lang.Object
org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject
org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject
org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.ArrayJsonSchemaObject
- All Implemented Interfaces:
JsonSchemaObject
- Enclosing class:
TypedJsonSchemaObject
JsonSchemaObject implementation of type : 'array' schema elements.Provides programmatic access to schema specifics like range, minItems, maxItems,... via a fluent API producing immutable
schema objects.- Since:
- 2.1
- Author:
- Christoph Strobl, Mark Paluch
-
Nested Class Summary
Nested classes/interfaces inherited from class TypedJsonSchemaObject
TypedJsonSchemaObject.ArrayJsonSchemaObject, TypedJsonSchemaObject.BooleanJsonSchemaObject, TypedJsonSchemaObject.NumericJsonSchemaObject, TypedJsonSchemaObject.ObjectJsonSchemaObject, TypedJsonSchemaObject.StringJsonSchemaObjectNested classes/interfaces inherited from interface JsonSchemaObject
JsonSchemaObject.Type -
Field Summary
Fields inherited from class TypedJsonSchemaObject
typesFields inherited from class UntypedJsonSchemaObject
description, generateDescription, restrictions -
Method Summary
Modifier and TypeMethodDescriptionadditionalItems(boolean additionalItemsAllowed) If set to false, no additional items besidesitems(Collection)are allowed.allOf(Collection<JsonSchemaObject> allOf) The field value must match all specified schemas.anyOf(Collection<JsonSchemaObject> anyOf) The field value must match at least one of the specified schemas.description(String description) Set the description.Auto generate the description if not explicitly set.protected StringCustomization hook for creating description out of defined values.
Called byTypedJsonSchemaObject.toDocument()when no explicitTypedJsonSchemaObject.description(String)is set.items(Collection<JsonSchemaObject> items) Define theitemsallowed in the array.maxItems(int count) Define the maxItems.minItems(int count) Define the maxItems.notMatch(JsonSchemaObject notMatch) The field value must not match the specified schemas.oneOf(Collection<JsonSchemaObject> oneOf) The field value must match exactly one of the specified schemas.possibleValues(Collection<? extends Object> possibleValues) enumerates all possible values of the field.Define the minItems and maxItems via the givenRange.
In-/Exclusions viarange boundsare not taken into account.org.bson.DocumentCreate the JSON schema complyingDocumentrepresentation.uniqueItems(boolean uniqueItems) Define the whether the array must contain unique items.Methods inherited from class TypedJsonSchemaObject
getTypes, ofMethods inherited from class UntypedJsonSchemaObject
newInstance
-
Method Details
-
uniqueItems
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject uniqueItems(boolean uniqueItems) Define the whether the array must contain unique items.- Parameters:
uniqueItems-- Returns:
- new instance of
TypedJsonSchemaObject.ArrayJsonSchemaObject.
-
range
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject range(Range<Integer> range) Define the minItems and maxItems via the givenRange.
In-/Exclusions viarange boundsare not taken into account.- Parameters:
range- must not be null. ConsiderRange.unbounded()instead.- Returns:
- new instance of
TypedJsonSchemaObject.ArrayJsonSchemaObject.
-
minItems
Define the maxItems.- Parameters:
count- the allowed minimal number of array items.- Returns:
- new instance of
TypedJsonSchemaObject.ArrayJsonSchemaObject.
-
maxItems
Define the maxItems.- Parameters:
count- the allowed maximal number of array items.- Returns:
- new instance of
TypedJsonSchemaObject.ArrayJsonSchemaObject.
-
items
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject items(Collection<JsonSchemaObject> items) Define theitemsallowed in the array.- Parameters:
items- the allowed items in the array.- Returns:
- new instance of
TypedJsonSchemaObject.ArrayJsonSchemaObject.
-
additionalItems
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject additionalItems(boolean additionalItemsAllowed) If set to false, no additional items besidesitems(Collection)are allowed.- Parameters:
additionalItemsAllowed- true to allow additional items in the array, false otherwise.- Returns:
- new instance of
TypedJsonSchemaObject.ArrayJsonSchemaObject.
-
possibleValues
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject possibleValues(Collection<? extends Object> possibleValues) Description copied from class:TypedJsonSchemaObjectenumerates all possible values of the field.- Overrides:
possibleValuesin classTypedJsonSchemaObject- Parameters:
possibleValues- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
allOf
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject allOf(Collection<JsonSchemaObject> allOf) Description copied from class:TypedJsonSchemaObjectThe field value must match all specified schemas.- Overrides:
allOfin classTypedJsonSchemaObject- Parameters:
allOf- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
anyOf
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject anyOf(Collection<JsonSchemaObject> anyOf) Description copied from class:TypedJsonSchemaObjectThe field value must match at least one of the specified schemas.- Overrides:
anyOfin classTypedJsonSchemaObject- Parameters:
anyOf- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
oneOf
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject oneOf(Collection<JsonSchemaObject> oneOf) Description copied from class:TypedJsonSchemaObjectThe field value must match exactly one of the specified schemas.- Overrides:
oneOfin classTypedJsonSchemaObject- Parameters:
oneOf- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
notMatch
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject notMatch(JsonSchemaObject notMatch) Description copied from class:TypedJsonSchemaObjectThe field value must not match the specified schemas.- Overrides:
notMatchin classTypedJsonSchemaObject- Parameters:
notMatch- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
description
@Contract("_ -> new") public TypedJsonSchemaObject.ArrayJsonSchemaObject description(String description) Description copied from class:TypedJsonSchemaObjectSet the description.- Overrides:
descriptionin classTypedJsonSchemaObject- Parameters:
description- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
generatedDescription
Description copied from class:TypedJsonSchemaObjectAuto generate the description if not explicitly set.- Overrides:
generatedDescriptionin classTypedJsonSchemaObject- Returns:
- new instance of
TypedJsonSchemaObject.
-
toDocument
public org.bson.Document toDocument()Description copied from class:TypedJsonSchemaObjectCreate the JSON schema complyingDocumentrepresentation. This includes type, description and the fields ofUntypedJsonSchemaObject.Restrictions.toDocument()if set.- Specified by:
toDocumentin interfaceJsonSchemaObject- Overrides:
toDocumentin classTypedJsonSchemaObject- Returns:
- never null.
-
generateDescription
Description copied from class:TypedJsonSchemaObjectCustomization hook for creating description out of defined values.
Called byTypedJsonSchemaObject.toDocument()when no explicitTypedJsonSchemaObject.description(String)is set.- Overrides:
generateDescriptionin classTypedJsonSchemaObject- Returns:
- can be null.
-