Package dev.morphia.mapping.codec.pojo
Class PropertyModelBuilder
- java.lang.Object
-
- dev.morphia.mapping.codec.pojo.PropertyModelBuilder
-
@MorphiaInternal 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
-
-
-
Method Detail
-
accessor
public PropertyAccessor<? super Object> accessor()
- Returns:
- the accessor for this model
-
accessor
public PropertyModelBuilder accessor(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
-
annotation
public PropertyModelBuilder annotation(Annotation annotation)
Adds an annotation- Parameters:
annotation
- the annotation- Returns:
- this
- Since:
- 2.3
-
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
-
discoverMappedName
@MorphiaInternal public PropertyModelBuilder discoverMappedName()
- Returns:
- the mapped name
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
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
-
name
public String name()
- Returns:
- the field name
-
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
-
mappedName
public String mappedName()
- Returns:
- the field's mapped name
-
modifiers
public int modifiers()
- Returns:
- the modifiers
-
modifiers
public PropertyModelBuilder modifiers(int modifiers)
- Parameters:
modifiers
-- Returns:
- the builder
-
name
public PropertyModelBuilder name(String name)
- Parameters:
name
-- Returns:
- the builder
-
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
-
-