Package org.bson.codecs.pojo
Class PropertyModelBuilder<T>
java.lang.Object
org.bson.codecs.pojo.PropertyModelBuilder<T>
- Type Parameters:
T- the type of the property
A builder for programmatically creating
PropertyModels.- Since:
- 3.5
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbsonRepresentation(BsonType bsonRepresentation) Sets the BsonRepresentationbuild()Creates thePropertyModel.Sets a custom codec for the propertydiscriminatorEnabled(boolean discriminatorEnabled) Enables or disables the use of a discriminator when serializingReturns the BsonRepresentationgetName()Returns thePropertyAccessorReturns the read annotations, to be applied when serializing to BSONReturns the write annotations, to be applied when deserializing from BSONbooleanProperty is readable.booleanProperty is writable.propertyAccessor(PropertyAccessor<T> propertyAccessor) Sets thePropertyAccessorpropertySerialization(PropertySerialization<T> propertySerialization) Sets thePropertySerializationcheckerreadAnnotations(List<Annotation> annotations) Sets the read annotations, to be applied when serializing to BSONSets the readName, the key for this property when deserializing the data from BSON.toString()writeAnnotations(List<Annotation> writeAnnotations) Sets the writeAnnotations, to be applied when deserializing from BSONSets the writeName, the key for this property when serializing the data into BSON.
-
Method Details
-
getName
- Returns:
- the property name
-
getReadName
- Returns:
- the name of the property to use as the key when deserializing the data from BSON.
-
readName
Sets the readName, the key for this property when deserializing the data from BSON.Note: A null means this property will not used when deserializing.
- Parameters:
readName- the name of the property to use as the key when deserializing the data from BSON.- Returns:
- this
-
getWriteName
- Returns:
- the name of the property to use as the key when serializing the data into BSON.
-
writeName
Sets the writeName, the key for this property when serializing the data into BSON.Note: A null means this property will not be serialized.
- Parameters:
writeName- the name of the property to use as the key when serializing the data into BSON.- Returns:
- this
-
codec
Sets a custom codec for the property- Parameters:
codec- the custom codec for the property- Returns:
- this
-
propertySerialization
public PropertyModelBuilder<T> propertySerialization(PropertySerialization<T> propertySerialization) Sets thePropertySerializationchecker- Parameters:
propertySerialization- checks if a property should be serialized- Returns:
- this
-
getPropertySerialization
- Returns:
- the
PropertySerializationchecker
-
getReadAnnotations
Returns the read annotations, to be applied when serializing to BSON- Returns:
- the read annotations
-
readAnnotations
Sets the read annotations, to be applied when serializing to BSON- Parameters:
annotations- the read annotations- Returns:
- this
-
getWriteAnnotations
Returns the write annotations, to be applied when deserializing from BSON- Returns:
- the write annotations
-
writeAnnotations
Sets the writeAnnotations, to be applied when deserializing from BSON- Parameters:
writeAnnotations- the writeAnnotations- Returns:
- this
-
isWritable
public boolean isWritable()Property is writable.- Returns:
- true if can be deserialized from BSON
-
isReadable
public boolean isReadable()Property is readable.- Returns:
- true if can be serialized to BSON
-
isDiscriminatorEnabled
- Returns:
- true or false if a discriminator should be used when serializing or null if not set
-
discriminatorEnabled
Enables or disables the use of a discriminator when serializing- Parameters:
discriminatorEnabled- the useDiscriminator value- Returns:
- this
-
getPropertyAccessor
Returns thePropertyAccessor- Returns:
- the PropertyAccessor
-
propertyAccessor
Sets thePropertyAccessor- Parameters:
propertyAccessor- the PropertyAccessor- Returns:
- this
-
getBsonRepresentation
Returns the BsonRepresentation- Returns:
- the BsonRepresentation
- Since:
- 4.2
-
bsonRepresentation
Sets the BsonRepresentation- Parameters:
bsonRepresentation- the BsonRepresentation- Returns:
- this
- Since:
- 4.2
-
build
Creates thePropertyModel.- Returns:
- the PropertyModel
-
toString
-