Package dev.morphia.mapping.codec.pojo
Class PropertyModel
- java.lang.Object
-
- dev.morphia.mapping.codec.pojo.PropertyModel
-
@MorphiaInternal public final class PropertyModel extends Object
Represents a field on a class and stores various metadata such as generic parameters.- 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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)PropertyAccessor<? super Object>getAccessor()<A extends Annotation>
AgetAnnotation(Class<A> type)Find an annotation of a specific type or null if not found.ObjectgetDocumentValue(Document document)EntityModelgetEntityModel()StringgetFullName()List<String>getLoadNames()StringgetMappedName()StringgetName()Class<?>getNormalizedType()Gets the parameterized type of a List or the key type of a Map, e.g.Class<?>getType()TypeData<?>getTypeData()ObjectgetValue(Object instance)Gets the value of the property mapped on the instance given.booleanhasAnnotation(Class<? extends Annotation> type)Indicates whether the annotation is present in the mapping (does not check the java field annotations, just the ones discovered)inthashCode()booleanisArray()booleanisMap()booleanisMultipleValues()booleanisReference()booleanisScalarValue()booleanisSet()booleanisTransient()static Class<?>normalize(TypeData<?> toNormalize)Gets the parameterized type of a TypeDatavoidsetValue(Object instance, Object value)Sets the value for the java fieldbooleanshouldSerialize(Object value)Checks a value against the configured rules for serializationCodec<?>specializeCodec(Datastore datastore)StringtoString()
-
-
-
Method Detail
-
normalize
@MorphiaInternal public static Class<?> normalize(TypeData<?> toNormalize)
Gets the parameterized type of a TypeData- Parameters:
toNormalize- the type to normalize- Returns:
- the unwrapped type
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getAccessor
public PropertyAccessor<? super Object> getAccessor()
- Returns:
- the accessor to use when accessing this field
-
getAnnotation
@Nullable public <A extends Annotation> A getAnnotation(Class<A> type)
Find an annotation of a specific type or null if not found.- Type Parameters:
A- the class type- Parameters:
type- the annotation type to find- Returns:
- the annotation instance or null
-
getDocumentValue
public Object getDocumentValue(Document document)
- Parameters:
document- the Document get the value from- Returns:
- the value from first mapping of this field
-
getEntityModel
public EntityModel getEntityModel()
- Returns:
- the entity model owner of this field
- Since:
- 2.1
-
getFullName
public String getFullName()
- Returns:
- the full name of the class plus java field name
-
getLoadNames
public List<String> getLoadNames()
- Returns:
- the name of the field's (key)name for mongodb, in order of loading.
-
getMappedName
public String getMappedName()
- Returns:
- the mapped name for the model
-
getName
public String getName()
- Returns:
- the field name for the model
-
getNormalizedType
public Class<?> getNormalizedType()
Gets the parameterized type of a List or the key type of a Map, e.g.- Returns:
- the unwrapped type
-
getType
public Class<?> getType()
- Returns:
- the type of this field
-
getTypeData
public TypeData<?> getTypeData()
- Returns:
- the type data for the field
-
getValue
@Nullable public Object getValue(Object instance)
Gets the value of the property mapped on the instance given.- Parameters:
instance- the instance to use- Returns:
- the value stored in the property
-
hasAnnotation
public boolean hasAnnotation(Class<? extends Annotation> type)
Indicates whether the annotation is present in the mapping (does not check the java field annotations, just the ones discovered)- Parameters:
type- the annotation to search for- Returns:
- true if the annotation was found
-
specializeCodec
@Nullable public Codec<?> specializeCodec(Datastore datastore)
- Parameters:
datastore-- Returns:
- the custom codec to use if set or null
-
isArray
public boolean isArray()
- Returns:
- true if the MappedField is an array
-
isMap
public boolean isMap()
- Returns:
- true if the MappedField is a Map
-
isMultipleValues
public boolean isMultipleValues()
- Returns:
- true if this field is a container type such as a List, Map, Set, or array
-
isReference
public boolean isReference()
-
isScalarValue
public boolean isScalarValue()
- Returns:
- true if this field is not a container type such as a List, Map, Set, or array
-
isSet
public boolean isSet()
- Returns:
- true if the MappedField is a Set
-
isTransient
public boolean isTransient()
- Returns:
- true if this field is marked as transient
-
setValue
public void setValue(Object instance, @Nullable Object value)
Sets the value for the java field- Parameters:
instance- the instance to updatevalue- the value to set
-
-