Package org.bson.codecs.pojo
Class ClassModelBuilder<T>
java.lang.Object
org.bson.codecs.pojo.ClassModelBuilder<T>
- Type Parameters:
T
- The type of the class the ClassModel represents
A builder for programmatically creating
ClassModels
.- Since:
- 3.5
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionannotations
(List<Annotation> annotations) Sets the annotations for the modelbuild()
Creates a new ClassModel instance based on the mapping data provided.conventions
(List<Convention> conventions) Sets the conventions to apply to the modeldiscriminator
(String discriminator) Sets the discriminator to be used when storing instances of the modeled typediscriminatorKey
(String discriminatorKey) Sets the discriminator key to be used when storing instances of the modeled typeenableDiscriminator
(boolean discriminatorEnabled) Enables or disables the use of a discriminator when serializingIdGenerator<?>
getProperty
(String propertyName) Gets a property by the property name.getType()
idGenerator
(IdGenerator<?> idGenerator) Sets the IdGenerator for the ClassModelidPropertyName
(String idPropertyName) Designates a property as the_id
property for this type.instanceCreatorFactory
(InstanceCreatorFactory<T> instanceCreatorFactory) Sets the InstanceCreatorFactory for the ClassModelboolean
removeProperty
(String propertyName) Remove a property from the buildertoString()
Sets the type of the model
-
Method Details
-
idGenerator
Sets the IdGenerator for the ClassModel- Parameters:
idGenerator
- the IdGenerator- Returns:
- this
- Since:
- 3.10
-
getIdGenerator
- Returns:
- the IdGenerator for the ClassModel, or null if not set
- Since:
- 3.10
-
instanceCreatorFactory
public ClassModelBuilder<T> instanceCreatorFactory(InstanceCreatorFactory<T> instanceCreatorFactory) Sets the InstanceCreatorFactory for the ClassModel- Parameters:
instanceCreatorFactory
- the InstanceCreatorFactory- Returns:
- this
-
getInstanceCreatorFactory
- Returns:
- the InstanceCreatorFactory for the ClassModel
-
type
Sets the type of the model- Parameters:
type
- the type of the class- Returns:
- the builder to configure the class being modeled
-
getType
- Returns:
- the type if set or null
-
conventions
Sets the conventions to apply to the model- Parameters:
conventions
- a list of conventions- Returns:
- this
-
getConventions
- Returns:
- the conventions o apply to the model
-
annotations
Sets the annotations for the model- Parameters:
annotations
- a list of annotations- Returns:
- this
-
getAnnotations
- Returns:
- the annotations on the modeled type if set or null
-
discriminator
Sets the discriminator to be used when storing instances of the modeled type- Parameters:
discriminator
- the discriminator value- Returns:
- this
-
getDiscriminator
- Returns:
- the discriminator to be used when storing instances of the modeled type or null if not set
-
discriminatorKey
Sets the discriminator key to be used when storing instances of the modeled type- Parameters:
discriminatorKey
- the discriminator key value- Returns:
- this
-
getDiscriminatorKey
- Returns:
- the discriminator key to be used when storing instances of the modeled type or null if not set
-
enableDiscriminator
Enables or disables the use of a discriminator when serializing- Parameters:
discriminatorEnabled
- true to enable the use of a discriminator- Returns:
- this
-
useDiscriminator
- Returns:
- true if a discriminator should be used when serializing, otherwise false
-
idPropertyName
Designates a property as the_id
property for this type. If another property is currently marked as the_id
property, that setting is cleared in favor of the named property.- Parameters:
idPropertyName
- the property name to use for the_id
property, a null value removes the set idPropertyName.- Returns:
- this
-
getIdPropertyName
- Returns:
- the designated
_id
property name for this type or null if not set
-
removeProperty
Remove a property from the builder- Parameters:
propertyName
- the actual property name in the POJO and not thedocumentPropertyName
.- Returns:
- returns true if the property matched and was removed
-
getProperty
Gets a property by the property name.- Parameters:
propertyName
- the name of the property to find.- Returns:
- the property or null if the property is not found
-
getPropertyModelBuilders
- Returns:
- the properties on the modeled type
-
build
Creates a new ClassModel instance based on the mapping data provided.- Returns:
- the new instance
-
toString
-