Package dev.morphia.mapping.codec.pojo
Class PropertyModelBuilder
- java.lang.Object
-
- dev.morphia.mapping.codec.pojo.PropertyModelBuilder
-
public final class PropertyModelBuilder 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()
PropertyModelBuilder
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 BSONPropertyModelBuilder
annotations(List<Annotation> annotations)
Sets the annotationsPropertyModel
build()
Creates thePropertyModel
.Datastore
datastore()
PropertyModelBuilder
discoverMappedName(MapperOptions options)
Boolean
discriminatorEnabled()
PropertyModelBuilder
discriminatorEnabled(Boolean discriminatorEnabled)
Enables/disables the use of the discriminator during mapping<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()
PropertyModelBuilder
mappedName(String mappedName)
Sets the field's mapped nameint
modifiers()
PropertyModelBuilder
modifiers(int modifiers)
String
name()
PropertyModelBuilder
name(String name)
EntityModel
owner()
PropertyModelBuilder
owner(EntityModel entityModel)
Sets the entity model ownerMorphiaPropertySerialization
serialization()
PropertyModelBuilder
serialization(MorphiaPropertySerialization propertySerialization)
Sets thePropertySerialization
checkerString
toString()
TypeData<?>
typeData()
PropertyModelBuilder
typeData(TypeData<?> typeData)
Sets the type data
-
-
-
Method Detail
-
discoverMappedName
public PropertyModelBuilder discoverMappedName(MapperOptions options)
-
accessor
public org.bson.codecs.pojo.PropertyAccessor<? super Object> accessor()
- Returns:
- the accessor for this model
-
accessor
public PropertyModelBuilder 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 PropertyModelBuilder annotations(List<Annotation> annotations)
Sets the annotations- Parameters:
annotations
- the annotations- Returns:
- this
-
annotations
public List<Annotation> annotations()
Returns the read annotations, to be applied when serializing to BSON- Returns:
- the read annotations
-
build
public PropertyModel build()
Creates thePropertyModel
.- Returns:
- the FieldModel
-
datastore
public Datastore datastore()
- Returns:
- the datastore in use
-
discriminatorEnabled
public PropertyModelBuilder discriminatorEnabled(Boolean discriminatorEnabled)
Enables/disables the use of the discriminator during mapping- Parameters:
discriminatorEnabled
- true if the discriminator should be used- Returns:
- this
-
discriminatorEnabled
public Boolean discriminatorEnabled()
- Returns:
- true if the discriminator is to be used
-
getAnnotation
@Nullable 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
-
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 PropertyModelBuilder 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
-
modifiers
public int modifiers()
-
modifiers
public PropertyModelBuilder modifiers(int modifiers)
-
name
public String name()
- Returns:
- the field name
-
name
public PropertyModelBuilder name(String name)
-
owner
public PropertyModelBuilder owner(EntityModel entityModel)
Sets the entity model owner- Parameters:
entityModel
- the entity model- Returns:
- this
- Since:
- 2.1
-
owner
public EntityModel owner()
- Returns:
- the entity model owner
- Since:
- 2.1
-
serialization
public PropertyModelBuilder serialization(MorphiaPropertySerialization propertySerialization)
Sets thePropertySerialization
checker- Parameters:
propertySerialization
- checks if a property should be serialized- Returns:
- this
-
serialization
public MorphiaPropertySerialization serialization()
- Returns:
- the PropertySerialization for this property
-
typeData
public TypeData<?> typeData()
- Returns:
- the type data
-
typeData
public PropertyModelBuilder typeData(TypeData<?> typeData)
Sets the type data- Parameters:
typeData
- the type data- Returns:
- this
-
-