Package dev.morphia.mapping.codec.pojo
Class FieldModelBuilder
- java.lang.Object
-
- dev.morphia.mapping.codec.pojo.FieldModelBuilder
-
public final class FieldModelBuilder extends Object
A builder for programmatically creatingFieldModels
.- Since:
- 2.0
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.bson.codecs.pojo.PropertyAccessor<? super Object>
accessor()
FieldModelBuilder
accessor(org.bson.codecs.pojo.PropertyAccessor<? super Object> accessor)
Sets thePropertyAccessor
void
alternateName(String name)
Adds an alternate nameList<String>
alternateNames()
List<Annotation>
annotations()
Returns the read annotations, to be applied when serializing to BSONFieldModelBuilder
annotations(List<Annotation> annotations)
Sets the annotationsFieldModel
build()
Creates theFieldModel
.org.bson.codecs.Codec<? super Object>
codec()
FieldModelBuilder
codec(org.bson.codecs.Codec<? super Object> codec)
Sets a custom codec for the fieldBoolean
discriminatorEnabled()
FieldModelBuilder
discriminatorEnabled(Boolean discriminatorEnabled)
Enables/disables the use of the discriminator during mappingEntityModel
entityModel()
FieldModelBuilder
entityModel(EntityModel entityModel)
Sets the entity model ownerField
field()
FieldModelBuilder
field(Field field)
Sets the field usedFieldModelBuilder
fieldName(String fieldName)
Sets the field name<A extends Annotation>
AgetAnnotation(Class<A> type)
Gets the annotation of this type.boolean
hasAnnotation(Class<? extends Annotation> type)
Checks this field for an annotation of the given typeString
mappedName()
FieldModelBuilder
mappedName(String mappedName)
Sets the field's mapped nameString
name()
org.bson.codecs.pojo.PropertySerialization<? super Object>
serialization()
FieldModelBuilder
serialization(org.bson.codecs.pojo.PropertySerialization<? super Object> propertySerialization)
Sets thePropertySerialization
checkerString
toString()
TypeData<?>
typeData()
FieldModelBuilder
typeData(TypeData<?> typeData)
Sets the type data
-
-
-
Method Detail
-
accessor
public org.bson.codecs.pojo.PropertyAccessor<? super Object> accessor()
- Returns:
- the accessor for this model
-
accessor
public FieldModelBuilder accessor(org.bson.codecs.pojo.PropertyAccessor<? super Object> accessor)
Sets thePropertyAccessor
- Parameters:
accessor
- the accessor- Returns:
- this
-
alternateName
public void alternateName(String name)
Adds an alternate name- Parameters:
name
- the new name
-
alternateNames
public List<String> alternateNames()
- Returns:
- the list of alternate names this model can be known by
- See Also:
AlsoLoad
-
annotations
public FieldModelBuilder annotations(List<Annotation> annotations)
Sets the annotations- Parameters:
annotations
- the annotations- Returns:
- this
-
build
public FieldModel build()
Creates theFieldModel
.- Returns:
- the FieldModel
-
codec
public FieldModelBuilder codec(org.bson.codecs.Codec<? super Object> codec)
Sets a custom codec for the field- Parameters:
codec
- the custom codec for the field- Returns:
- this
-
codec
public org.bson.codecs.Codec<? super Object> codec()
- Returns:
- the code
- Since:
- 2.1
-
discriminatorEnabled
public FieldModelBuilder discriminatorEnabled(Boolean discriminatorEnabled)
Enables/disables the use of the discriminator during mapping- Parameters:
discriminatorEnabled
- true if the discriminator should be used- Returns:
- this
-
entityModel
public FieldModelBuilder entityModel(EntityModel entityModel)
Sets the entity model owner- Parameters:
entityModel
- the entity model- Returns:
- this
- Since:
- 2.1
-
entityModel
public EntityModel entityModel()
- Returns:
- the entity model owner
- Since:
- 2.1
-
field
public FieldModelBuilder field(Field field)
Sets the field used- Parameters:
field
- the field- Returns:
- this
-
fieldName
public FieldModelBuilder fieldName(String fieldName)
Sets the field name- Parameters:
fieldName
- the name- Returns:
- this
-
getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> type)
Gets the annotation of this type.- Type Parameters:
A
- the annotation type- Parameters:
type
- the annotation class- Returns:
- the annotation instance or null if this annotation is on the field
-
annotations
public List<Annotation> annotations()
Returns the read annotations, to be applied when serializing to BSON- Returns:
- the read annotations
-
discriminatorEnabled
public Boolean discriminatorEnabled()
- Returns:
- true if the discriminator is to be used
-
field
public Field field()
- Returns:
- the field
-
name
public String name()
- Returns:
- the field name
-
typeData
public TypeData<?> typeData()
- Returns:
- the type data
-
hasAnnotation
public boolean hasAnnotation(Class<? extends Annotation> type)
Checks this field for an annotation of the given type- Parameters:
type
- the annotation class- Returns:
- true if the annotation is used on this field
-
mappedName
public FieldModelBuilder mappedName(String mappedName)
Sets the field's mapped name- Parameters:
mappedName
- the name- Returns:
- this
-
mappedName
public String mappedName()
- Returns:
- the field's mapped name
-
serialization
public FieldModelBuilder serialization(org.bson.codecs.pojo.PropertySerialization<? super Object> propertySerialization)
Sets thePropertySerialization
checker- Parameters:
propertySerialization
- checks if a property should be serialized- Returns:
- this
-
serialization
public org.bson.codecs.pojo.PropertySerialization<? super Object> serialization()
- Returns:
- the PropertySerialization for this property
-
typeData
public FieldModelBuilder typeData(TypeData<?> typeData)
Sets the type data- Parameters:
typeData
- the type data- Returns:
- this
-
-