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
public final class PropertyModelBuilder<T> extends Object
A builder for programmatically creatingPropertyModels
.- Since:
- 3.5
- See Also:
PropertyModel
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertyModelBuilder<T>
bsonRepresentation(BsonType bsonRepresentation)
Sets the BsonRepresentationPropertyModel<T>
build()
Creates thePropertyModel
.PropertyModelBuilder<T>
codec(Codec<T> codec)
Sets a custom codec for the propertyPropertyModelBuilder<T>
discriminatorEnabled(boolean discriminatorEnabled)
Enables or disables the use of a discriminator when serializingBsonType
getBsonRepresentation()
Returns the BsonRepresentationString
getName()
PropertyAccessor<T>
getPropertyAccessor()
Returns thePropertyAccessor
PropertySerialization<T>
getPropertySerialization()
List<Annotation>
getReadAnnotations()
Returns the read annotations, to be applied when serializing to BSONString
getReadName()
List<Annotation>
getWriteAnnotations()
Returns the write annotations, to be applied when deserializing from BSONString
getWriteName()
Boolean
isDiscriminatorEnabled()
boolean
isReadable()
Property is readable.boolean
isWritable()
Property is writable.PropertyModelBuilder<T>
propertyAccessor(PropertyAccessor<T> propertyAccessor)
Sets thePropertyAccessor
PropertyModelBuilder<T>
propertySerialization(PropertySerialization<T> propertySerialization)
Sets thePropertySerialization
checkerPropertyModelBuilder<T>
readAnnotations(List<Annotation> annotations)
Sets the read annotations, to be applied when serializing to BSONPropertyModelBuilder<T>
readName(String readName)
Sets the readName, the key for this property when deserializing the data from BSON.String
toString()
PropertyModelBuilder<T>
writeAnnotations(List<Annotation> writeAnnotations)
Sets the writeAnnotations, to be applied when deserializing from BSONPropertyModelBuilder<T>
writeName(String writeName)
Sets the writeName, the key for this property when serializing the data into BSON.
-
-
-
Method Detail
-
getName
public String getName()
- Returns:
- the property name
-
getReadName
public String getReadName()
- Returns:
- the name of the property to use as the key when deserializing the data from BSON.
-
readName
public PropertyModelBuilder<T> readName(String 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
public String getWriteName()
- Returns:
- the name of the property to use as the key when serializing the data into BSON.
-
writeName
public PropertyModelBuilder<T> writeName(String 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
public PropertyModelBuilder<T> codec(Codec<T> 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 thePropertySerialization
checker- Parameters:
propertySerialization
- checks if a property should be serialized- Returns:
- this
-
getPropertySerialization
public PropertySerialization<T> getPropertySerialization()
- Returns:
- the
PropertySerialization
checker
-
getReadAnnotations
public List<Annotation> getReadAnnotations()
Returns the read annotations, to be applied when serializing to BSON- Returns:
- the read annotations
-
readAnnotations
public PropertyModelBuilder<T> readAnnotations(List<Annotation> annotations)
Sets the read annotations, to be applied when serializing to BSON- Parameters:
annotations
- the read annotations- Returns:
- this
-
getWriteAnnotations
public List<Annotation> getWriteAnnotations()
Returns the write annotations, to be applied when deserializing from BSON- Returns:
- the write annotations
-
writeAnnotations
public PropertyModelBuilder<T> writeAnnotations(List<Annotation> 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
public Boolean isDiscriminatorEnabled()
- Returns:
- true or false if a discriminator should be used when serializing or null if not set
-
discriminatorEnabled
public PropertyModelBuilder<T> discriminatorEnabled(boolean discriminatorEnabled)
Enables or disables the use of a discriminator when serializing- Parameters:
discriminatorEnabled
- the useDiscriminator value- Returns:
- this
-
getPropertyAccessor
public PropertyAccessor<T> getPropertyAccessor()
Returns thePropertyAccessor
- Returns:
- the PropertyAccessor
-
propertyAccessor
public PropertyModelBuilder<T> propertyAccessor(PropertyAccessor<T> propertyAccessor)
Sets thePropertyAccessor
- Parameters:
propertyAccessor
- the PropertyAccessor- Returns:
- this
-
getBsonRepresentation
public BsonType getBsonRepresentation()
Returns the BsonRepresentation- Returns:
- the BsonRepresentation
- Since:
- 4.2
-
bsonRepresentation
public PropertyModelBuilder<T> bsonRepresentation(BsonType bsonRepresentation)
Sets the BsonRepresentation- Parameters:
bsonRepresentation
- the BsonRepresentation- Returns:
- this
- Since:
- 4.2
-
build
public PropertyModel<T> build()
Creates thePropertyModel
.- Returns:
- the PropertyModel
-
-