Interface JsonSchemaObject
- All Known Subinterfaces:
JsonSchemaProperty
- All Known Implementing Classes:
IdentifiableJsonSchemaProperty
,IdentifiableJsonSchemaProperty.ArrayJsonSchemaProperty
,IdentifiableJsonSchemaProperty.BooleanJsonSchemaProperty
,IdentifiableJsonSchemaProperty.DateJsonSchemaProperty
,IdentifiableJsonSchemaProperty.EncryptedJsonSchemaProperty
,IdentifiableJsonSchemaProperty.NullJsonSchemaProperty
,IdentifiableJsonSchemaProperty.NumericJsonSchemaProperty
,IdentifiableJsonSchemaProperty.ObjectJsonSchemaProperty
,IdentifiableJsonSchemaProperty.RequiredJsonSchemaProperty
,IdentifiableJsonSchemaProperty.StringJsonSchemaProperty
,IdentifiableJsonSchemaProperty.TimestampJsonSchemaProperty
,IdentifiableJsonSchemaProperty.UntypedJsonSchemaProperty
,TypedJsonSchemaObject
,TypedJsonSchemaObject.ArrayJsonSchemaObject
,TypedJsonSchemaObject.BooleanJsonSchemaObject
,TypedJsonSchemaObject.NumericJsonSchemaObject
,TypedJsonSchemaObject.ObjectJsonSchemaObject
,TypedJsonSchemaObject.StringJsonSchemaObject
,UntypedJsonSchemaObject
public interface JsonSchemaObject
Interface that can be implemented by objects that know how to serialize themselves to JSON schema using
This class also declares factory methods for type-specific
toDocument()
.
This class also declares factory methods for type-specific
schema objects
such as
string()
or object()
. For example:
JsonSchemaProperty.object("address").properties(JsonSchemaProperty.string("city").minLength(3));
- Since:
- 2.1
- Author:
- Christoph Strobl, Mark Paluch
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Type represents either a JSON schema type or a MongoDB specific bsonType. -
Method Summary
Modifier and TypeMethodDescriptionarray()
Create a newJsonSchemaObject
oftype : 'array'
.bool()
Create a newJsonSchemaObject
oftype : 'boolean'
.static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.DateJsonSchemaObject
date()
Create a newJsonSchemaObject
oftype : 'date'
.getTypes()
Get the set of types defined for this schema element.
TheSet
is likely to contain only one element in most cases.static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.NullJsonSchemaObject
nil()
Create a newJsonSchemaObject
oftype : 'null'
.number()
Create a newJsonSchemaObject
oftype : 'number'
.object()
Create a newJsonSchemaObject
oftype : 'object'
.static TypedJsonSchemaObject
Create a newJsonSchemaObject
matching the giventype
.static TypedJsonSchemaObject
of
(JsonSchemaObject.Type type) Create a newJsonSchemaObject
of givenJsonSchemaObject.Type
.string()
Create a newJsonSchemaObject
oftype : 'string'
.static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.TimestampJsonSchemaObject
Create a newJsonSchemaObject
oftype : 'timestamp'
.org.bson.Document
Get the MongoDB specific representation.
The Document may contain fields (eg. like bsonType) not contained in the JsonSchema specification.static UntypedJsonSchemaObject
untyped()
Create a newUntypedJsonSchemaObject
.
-
Method Details
-
getTypes
Set<JsonSchemaObject.Type> getTypes()Get the set of types defined for this schema element.
TheSet
is likely to contain only one element in most cases.- Returns:
- never null.
-
toDocument
org.bson.Document toDocument()Get the MongoDB specific representation.
The Document may contain fields (eg. like bsonType) not contained in the JsonSchema specification. It may also contain types not directly processable by the MongoDB java driver. Make sure to run the producedDocument
through the mapping infrastructure.- Returns:
- never null.
-
object
Create a newJsonSchemaObject
oftype : 'object'
.- Returns:
- never null.
-
string
Create a newJsonSchemaObject
oftype : 'string'
.- Returns:
- never null.
-
number
Create a newJsonSchemaObject
oftype : 'number'
.- Returns:
- never null.
-
array
Create a newJsonSchemaObject
oftype : 'array'
.- Returns:
- never null.
-
bool
Create a newJsonSchemaObject
oftype : 'boolean'
.- Returns:
- never null.
-
nil
static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.NullJsonSchemaObject nil()Create a newJsonSchemaObject
oftype : 'null'
.- Returns:
- never null.
-
date
static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.DateJsonSchemaObject date()Create a newJsonSchemaObject
oftype : 'date'
.- Returns:
- never null.
-
timestamp
static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.TimestampJsonSchemaObject timestamp()Create a newJsonSchemaObject
oftype : 'timestamp'
.- Returns:
- never null.
-
of
Create a newJsonSchemaObject
of givenJsonSchemaObject.Type
.- Returns:
- never null.
-
untyped
Create a newUntypedJsonSchemaObject
.- Returns:
- never null.
-
of
Create a newJsonSchemaObject
matching the giventype
.- Parameters:
type
- Java class to create aJsonSchemaObject
for. May be null to createnull
type.- Returns:
- never null.
- Throws:
IllegalArgumentException
- iftype
is not supported.
-