Class UntypedJsonSchemaObject
java.lang.Object
org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject
- All Implemented Interfaces:
JsonSchemaObject
- Direct Known Subclasses:
TypedJsonSchemaObject
Common base for
JsonSchemaObject
with shared types and JsonSchemaObject.toDocument()
implementation.
Schema objects are immutable. Calling methods to configure properties creates a new object instance.- Since:
- 2.1
- Author:
- Christoph Strobl, Mark Paluch
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.schema.JsonSchemaObject
JsonSchemaObject.Type
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final String
protected final boolean
protected final org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject.Restrictions
-
Method Summary
Modifier and TypeMethodDescriptionallOf
(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 bytoDocument()
when no explicitdescription
is set.getTypes()
Get the set of types defined for this schema element.
TheSet
is likely to contain only one element in most cases.static UntypedJsonSchemaObject
Create a new instance ofUntypedJsonSchemaObject
.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.org.bson.Document
Create the JSON schema complyingDocument
representation.
-
Field Details
-
restrictions
protected final org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject.Restrictions restrictions -
description
-
generateDescription
protected final boolean generateDescription
-
-
Method Details
-
newInstance
Create a new instance ofUntypedJsonSchemaObject
.- Returns:
- the new
UntypedJsonSchemaObject
.
-
getTypes
Description copied from interface:JsonSchemaObject
Get the set of types defined for this schema element.
TheSet
is likely to contain only one element in most cases.- Specified by:
getTypes
in interfaceJsonSchemaObject
- Returns:
- never null.
-
description
Set the description.- Parameters:
description
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
generatedDescription
Auto generate the description if not explicitly set.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
possibleValues
enumerates all possible values of the field.- Parameters:
possibleValues
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
allOf
The field value must match all specified schemas.- Parameters:
allOf
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
anyOf
The field value must match at least one of the specified schemas.- Parameters:
anyOf
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
oneOf
The field value must match exactly one of the specified schemas.- Parameters:
oneOf
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
notMatch
The field value must not match the specified schemas.- Parameters:
notMatch
- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject
.
-
toDocument
public org.bson.Document toDocument()Create the JSON schema complyingDocument
representation. This includes type, description and the fields ofUntypedJsonSchemaObject.Restrictions.toDocument()
if set.- Specified by:
toDocument
in interfaceJsonSchemaObject
- Returns:
- never null.
-
generateDescription
Customization hook for creating description out of defined values.
Called bytoDocument()
when no explicitdescription
is set.- Returns:
- can be null.
-