Module spring.data.mongodb
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.QueryableJsonSchemaProperty,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 interfaceType represents either a JSON schema type or a MongoDB specific bsonType. -
Method Summary
Modifier and TypeMethodDescriptionarray()Create a newJsonSchemaObjectoftype : 'array'.bool()Create a newJsonSchemaObjectoftype : 'boolean'.static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.DateJsonSchemaObjectdate()Create a newJsonSchemaObjectoftype : 'date'.getTypes()Get the set of types defined for this schema element.
TheSetis likely to contain only one element in most cases.static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.NullJsonSchemaObjectnil()Create a newJsonSchemaObjectoftype : 'null'.number()Create a newJsonSchemaObjectoftype : 'number'.object()Create a newJsonSchemaObjectoftype : 'object'.static TypedJsonSchemaObjectCreate a newJsonSchemaObjectmatching the giventype.static TypedJsonSchemaObjectof(JsonSchemaObject.Type type) Create a newJsonSchemaObjectof givenJsonSchemaObject.Type.string()Create a newJsonSchemaObjectoftype : 'string'.static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.TimestampJsonSchemaObjectCreate a newJsonSchemaObjectoftype : 'timestamp'.org.bson.DocumentGet the MongoDB specific representation.
The Document may contain fields (eg. like bsonType) not contained in the JsonSchema specification.static UntypedJsonSchemaObjectuntyped()Create a newUntypedJsonSchemaObject.
-
Method Details
-
getTypes
Set<JsonSchemaObject.Type> getTypes()Get the set of types defined for this schema element.
TheSetis 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 producedDocumentthrough the mapping infrastructure.- Returns:
- never null.
-
object
Create a newJsonSchemaObjectoftype : 'object'.- Returns:
- never null.
-
string
Create a newJsonSchemaObjectoftype : 'string'.- Returns:
- never null.
-
number
Create a newJsonSchemaObjectoftype : 'number'.- Returns:
- never null.
-
array
Create a newJsonSchemaObjectoftype : 'array'.- Returns:
- never null.
-
bool
Create a newJsonSchemaObjectoftype : 'boolean'.- Returns:
- never null.
-
nil
static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.NullJsonSchemaObject nil()Create a newJsonSchemaObjectoftype : 'null'.- Returns:
- never null.
-
date
static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.DateJsonSchemaObject date()Create a newJsonSchemaObjectoftype : 'date'.- Returns:
- never null.
-
timestamp
static org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.TimestampJsonSchemaObject timestamp()Create a newJsonSchemaObjectoftype : 'timestamp'.- Returns:
- never null.
-
of
Create a newJsonSchemaObjectof givenJsonSchemaObject.Type.- Returns:
- never null.
-
untyped
Create a newUntypedJsonSchemaObject.- Returns:
- never null.
-
of
Create a newJsonSchemaObjectmatching the giventype.- Parameters:
type- Java class to create aJsonSchemaObjectfor. May be null to createnulltype.- Returns:
- never null.
- Throws:
IllegalArgumentException- iftypeis not supported.
-