Class TypedJsonSchemaObject.StringJsonSchemaObject
java.lang.Object
org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject
org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject
org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject.StringJsonSchemaObject
- All Implemented Interfaces:
JsonSchemaObject
- Enclosing class:
- TypedJsonSchemaObject
JsonSchemaObject implementation of type : 'string' schema elements.Provides programmatic access to schema specifics like minLength, maxLength, pattern,... 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.StringJsonSchemaObjectNested 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
typesFields inherited from class org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject
description, generateDescription, 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 StringCustomization hook for creating description out of defined values.
Called byTypedJsonSchemaObject.toDocument()when no explicitTypedJsonSchemaObject.description(java.lang.String)is set.Define the valid length range (minLength and maxLength) for a valid field.Define the regex pattern to validate field values against.maxLength(int length) Define the valid length range (maxLength) for a valid field.minLength(int length) Define the valid length range (minLength) for a valid field.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.DocumentCreate the JSON schema complyingDocumentrepresentation.Methods inherited from class org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject
getTypes, ofMethods inherited from class org.springframework.data.mongodb.core.schema.UntypedJsonSchemaObject
newInstance
-
Method Details
-
length
Define the valid length range (minLength and maxLength) for a valid field.- Parameters:
range- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.StringJsonSchemaObject.
-
minLength
Define the valid length range (minLength) for a valid field.- Parameters:
length-- Returns:
- new instance of
TypedJsonSchemaObject.StringJsonSchemaObject.
-
maxLength
Define the valid length range (maxLength) for a valid field.- Parameters:
length-- Returns:
- new instance of
TypedJsonSchemaObject.StringJsonSchemaObject.
-
matching
Define the regex pattern to validate field values against.- Parameters:
pattern- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.StringJsonSchemaObject.
-
possibleValues
public TypedJsonSchemaObject.StringJsonSchemaObject possibleValues(Collection<? extends Object> possibleValues) Description copied from class:TypedJsonSchemaObjectenumerates all possible values of the field.- Overrides:
possibleValuesin classTypedJsonSchemaObject- Parameters:
possibleValues- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
allOf
Description copied from class:TypedJsonSchemaObjectThe field value must match all specified schemas.- Overrides:
allOfin classTypedJsonSchemaObject- Parameters:
allOf- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
anyOf
Description copied from class:TypedJsonSchemaObjectThe field value must match at least one of the specified schemas.- Overrides:
anyOfin classTypedJsonSchemaObject- Parameters:
anyOf- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
oneOf
Description copied from class:TypedJsonSchemaObjectThe field value must match exactly one of the specified schemas.- Overrides:
oneOfin classTypedJsonSchemaObject- Parameters:
oneOf- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
notMatch
Description copied from class:TypedJsonSchemaObjectThe field value must not match the specified schemas.- Overrides:
notMatchin classTypedJsonSchemaObject- Parameters:
notMatch- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
description
Description copied from class:TypedJsonSchemaObjectSet the description.- Overrides:
descriptionin classTypedJsonSchemaObject- Parameters:
description- must not be null.- Returns:
- new instance of
TypedJsonSchemaObject.
-
generatedDescription
Description copied from class:TypedJsonSchemaObjectAuto generate the description if not explicitly set.- Overrides:
generatedDescriptionin classTypedJsonSchemaObject- Returns:
- new instance of
TypedJsonSchemaObject.
-
toDocument
public org.bson.Document toDocument()Description copied from class:TypedJsonSchemaObjectCreate the JSON schema complyingDocumentrepresentation. This includes type, description and the fields ofUntypedJsonSchemaObject.Restrictions.toDocument()if set.- Specified by:
toDocumentin interfaceJsonSchemaObject- Overrides:
toDocumentin classTypedJsonSchemaObject- Returns:
- never null.
-
generateDescription
Description copied from class:TypedJsonSchemaObjectCustomization hook for creating description out of defined values.
Called byTypedJsonSchemaObject.toDocument()when no explicitTypedJsonSchemaObject.description(java.lang.String)is set.- Overrides:
generateDescriptionin classTypedJsonSchemaObject- Returns:
- can be null.
-