Module spring.data.mongodb
Interface MongoJsonSchemaCreator
public interface MongoJsonSchemaCreator
MongoJsonSchemaCreator extracts the MongoJsonSchema for a given Class by applying the
following mapping rules.
Required Properties
- Properties of primitive type
- All properties annotated with
Transient
Object->type : 'object'Arrays->type : 'array'Collection->type : 'array'Map->type : 'object'Enum->type : 'string', enum : [the enum values]- Simple Types ->
type : 'the corresponding bson type' - Domain Types ->
type : 'object', properties : {the types properties}
_id properties using types that can be converted into
ObjectId like String will be mapped to type : 'object' unless there is more
specific information available via the MongoId annotation.
Encrypted properties will contain encrypt information.- Since:
- 2.2
- Author:
- Christoph Strobl
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe context in which a specificMongoJsonSchemaCreator.JsonSchemaPropertyContext.getProperty()is encountered during schema creation.static interface -
Method Summary
Modifier and TypeMethodDescriptionstatic MongoJsonSchemaCreatorcreate()Creates a newMongoJsonSchemaCreatorthat does not consider potential extensions - suitable for testing.static MongoJsonSchemaCreatorcreate(MappingContext mappingContext) Creates a newMongoJsonSchemaCreatorthat is aware of type mappings and potentialextensions.static MongoJsonSchemaCreatorcreate(MongoConverter mongoConverter) Creates a newMongoJsonSchemaCreatorthat is aware of conversions applied by the givenMongoConverter.createSchemaFor(Class<?> type) Create theMongoJsonSchemafor the giventype.A filterPredicatethat matchesencrypted propertiesand those having nested ones.Filter matchingproperties.default MongoJsonSchemamergedSchemaFor(Class<?>... types) Create a mergedMongoJsonSchemaout of the individual schemas of the given types by merging their properties into one largeschema.Entry point to specify additional behavior for a given path.
-
Method Details
-
createSchemaFor
Create theMongoJsonSchemafor the giventype.- Parameters:
type- must not be null.- Returns:
- never null.
-
mergedSchemaFor
Create a mergedMongoJsonSchemaout of the individual schemas of the given types by merging their properties into one largeschema.- Parameters:
types- must not be null nor contain null.- Returns:
- new instance of
MongoJsonSchema. - Since:
- 3.4
-
filter
Filter matchingproperties.- Parameters:
filter- thePredicateto evaluate for inclusion. Must not be null.- Returns:
- new instance of
MongoJsonSchemaCreator. - Since:
- 3.3
-
property
Entry point to specify additional behavior for a given path.- Parameters:
path- the path using dot '.' notation.- Returns:
- new instance of
MongoJsonSchemaCreator.PropertySpecifier. - Since:
- 3.4
-
encryptedOnly
A filterPredicatethat matchesencrypted propertiesand those having nested ones.- Returns:
- new instance of
Predicate. - Since:
- 3.3
-
create
Creates a newMongoJsonSchemaCreatorthat is aware of conversions applied by the givenMongoConverter.- Parameters:
mongoConverter- must not be null.- Returns:
- new instance of
MongoJsonSchemaCreator.
-
create
Creates a newMongoJsonSchemaCreatorthat is aware of type mappings and potentialextensions.- Parameters:
mappingContext- must not be null.- Returns:
- new instance of
MongoJsonSchemaCreator. - Since:
- 3.3
-
create
Creates a newMongoJsonSchemaCreatorthat does not consider potential extensions - suitable for testing. We recommend to usecreate(MappingContext).- Returns:
- new instance of
MongoJsonSchemaCreator. - Since:
- 3.3
-