Class TypedJsonSchemaObject.ObjectJsonSchemaObject
java.lang.Object
org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject
org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject
org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.ObjectJsonSchemaObject
- All Implemented Interfaces:
JsonSchemaObject
- Enclosing class:
- TypedJsonSchemaObject
JsonSchemaObject
implementation of type : 'object'
schema elements.Provides programmatic access to schema specifics like required, properties, patternProperties,... via a fluent API producing immutable
schema objects
.- Since:
- 2.1
- Author:
- Christoph Strobl
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject
TypedJsonSchemaObject.ArrayJsonSchemaObject, TypedJsonSchemaObject.BooleanJsonSchemaObject, TypedJsonSchemaObject.NumericJsonSchemaObject, TypedJsonSchemaObject.ObjectJsonSchemaObject, TypedJsonSchemaObject.StringJsonSchemaObject
Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.schema.JsonSchemaObject
JsonSchemaObject.Type
-
Field Summary
Fields inherited from class org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject
types
Fields inherited from class org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject
description, generateDescription, restrictions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadditionalProperties
(boolean additionalPropertiesAllowed) If set to false, additional fields besidesproperties(JsonSchemaProperty...)
/patternProperties(JsonSchemaProperty...)
are not allowed.If specified, additional fields must validate against the given schema.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 String
Customization hook for creating description out of defined values.
Called byTypedJsonSchemaObject.toDocument()
when no explicitTypedJsonSchemaObject.description(java.lang.String)
is set.maxProperties
(int count) Define the maxProperties.minProperties
(int count) Define the minProperties.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.patternProperties
(JsonSchemaProperty... regularExpressions) Append regular expression patterns along with theJsonSchemaObject
matching properties validating against.possibleValues
(Collection<? extends Object> possibleValues) enumerates all possible values of the field.properties
(JsonSchemaProperty... properties) Append the objects properties along with theJsonSchemaObject
validating against.propertiesCount
(Range<Integer> range) Define the minProperties and maxProperties via the givenRange
.
In-/Exclusions viarange bounds
are not taken into account.property
(JsonSchemaProperty property) Append the objects property along with theJsonSchemaObject
validating against.Define the Object’s required properties.org.bson.Document
Create the JSON schema complyingDocument
representation.Methods inherited from class org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject
getTypes, of
Methods inherited from class org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject
newInstance
-
Constructor Details
-
ObjectJsonSchemaObject
public ObjectJsonSchemaObject()
-
-
Method Details
-
propertiesCount
Define the minProperties and maxProperties via the givenRange
.
In-/Exclusions viarange bounds
are not taken into account.- Parameters:
range
- must not be null. ConsiderRange.unbounded()
instead.- Returns:
- new instance of
TypedJsonSchemaObject.ObjectJsonSchemaObject
.
-
minProperties
Define the minProperties.- Parameters:
count
- the allowed minimal number of properties.- Returns:
- new instance of
TypedJsonSchemaObject.ObjectJsonSchemaObject
.
-
maxProperties
Define the maxProperties.- Parameters:
count
- the allowed maximum number of properties.- Returns:
- new instance of
TypedJsonSchemaObject.ObjectJsonSchemaObject
.
-
required
Define the Object’s required properties.- Parameters:
properties
- the names of required properties.- Returns:
- new instance of
TypedJsonSchemaObject.ObjectJsonSchemaObject
.
-
additionalProperties
public TypedJsonSchemaObject.ObjectJsonSchemaObject additionalProperties(boolean additionalPropertiesAllowed) If set to false, additional fields besidesproperties(JsonSchemaProperty...)
/patternProperties(JsonSchemaProperty...)
are not allowed.- Parameters:
additionalPropertiesAllowed
-- Returns:
- new instance of
TypedJsonSchemaObject.ObjectJsonSchemaObject
.
-
additionalProperties
public TypedJsonSchemaObject.ObjectJsonSchemaObject additionalProperties(TypedJsonSchemaObject.ObjectJsonSchemaObject schema) If specified, additional fields must validate against the given schema.- Parameters:
schema
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.ObjectJsonSchemaObject
.
-
properties
Append the objects properties along with theJsonSchemaObject
validating against.- Parameters:
properties
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.ObjectJsonSchemaObject
.
-
patternProperties
public TypedJsonSchemaObject.ObjectJsonSchemaObject patternProperties(JsonSchemaProperty... regularExpressions) Append regular expression patterns along with theJsonSchemaObject
matching properties validating against.- Parameters:
regularExpressions
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.ObjectJsonSchemaObject
.
-
property
Append the objects property along with theJsonSchemaObject
validating against.- Parameters:
property
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.ObjectJsonSchemaObject
.
-
possibleValues
public TypedJsonSchemaObject.ObjectJsonSchemaObject possibleValues(Collection<? extends Object> possibleValues) Description copied from class:TypedJsonSchemaObject
enumerates all possible values of the field.- Overrides:
possibleValues
in classTypedJsonSchemaObject
- Parameters:
possibleValues
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
allOf
Description copied from class:TypedJsonSchemaObject
The field value must match all specified schemas.- Overrides:
allOf
in classTypedJsonSchemaObject
- Parameters:
allOf
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
anyOf
Description copied from class:TypedJsonSchemaObject
The field value must match at least one of the specified schemas.- Overrides:
anyOf
in classTypedJsonSchemaObject
- Parameters:
anyOf
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
oneOf
Description copied from class:TypedJsonSchemaObject
The field value must match exactly one of the specified schemas.- Overrides:
oneOf
in classTypedJsonSchemaObject
- Parameters:
oneOf
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
notMatch
Description copied from class:TypedJsonSchemaObject
The field value must not match the specified schemas.- Overrides:
notMatch
in classTypedJsonSchemaObject
- Parameters:
notMatch
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
description
Description copied from class:TypedJsonSchemaObject
Set the description.- Overrides:
description
in classTypedJsonSchemaObject
- Parameters:
description
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
generatedDescription
Description copied from class:TypedJsonSchemaObject
Auto generate the description if not explicitly set.- Overrides:
generatedDescription
in classTypedJsonSchemaObject
- Returns:
- new instance of
TypedJsonSchemaObject
.
-
getProperties
-
toDocument
public org.bson.Document toDocument()Description copied from class:TypedJsonSchemaObject
Create the JSON schema complyingDocument
representation. This includes type, description and the fields ofUntypedJsonSchemaObject.Restrictions.toDocument()
if set.- Specified by:
toDocument
in interfaceJsonSchemaObject
- Overrides:
toDocument
in classTypedJsonSchemaObject
- Returns:
- never null.
-
generateDescription
Description copied from class:TypedJsonSchemaObject
Customization hook for creating description out of defined values.
Called byTypedJsonSchemaObject.toDocument()
when no explicitTypedJsonSchemaObject.description(java.lang.String)
is set.- Overrides:
generateDescription
in classTypedJsonSchemaObject
- Returns:
- can be null.
-