Package dev.morphia.mapping
Class EphemeralMappedField
- java.lang.Object
-
- dev.morphia.mapping.MappedField
-
- dev.morphia.mapping.EphemeralMappedField
-
public class EphemeralMappedField extends MappedField
This is a MappedField facade that allows us to convert and collect values to be gathered back in to a Map or Collection, e.g., rather than directly on a mapped entity. This are not mapped directly to a field on a class like MappedFields are.
-
-
Constructor Summary
Constructors Constructor Description EphemeralMappedField(java.lang.reflect.ParameterizedType t, MappedField mf, Mapper mapper)Creates an EphemeralMappedField.EphemeralMappedField(java.lang.reflect.Type t, MappedField mf, Mapper mapper)Creates an EphemeralMappedField.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)Adds the annotation, if it exists on the field.voidaddAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz, java.lang.annotation.Annotation ann)Adds the annotation, if it exists on the field.java.lang.ObjectgetDbObjectValue(com.mongodb.DBObject dbObj)java.lang.ObjectgetFieldValue(java.lang.Object instance)Gets the value of the field mapped on the instance given.java.lang.ClassgetMapKeyClass()If the underlying java type is a map then it returns T from Map<T,V>java.lang.StringgetMappedFieldName()java.lang.StringgetNameToStore()MappedFieldgetParent()java.lang.ClassgetSubClass()If the java field is a list/array/map then the sub-type T is returned (ex.java.lang.reflect.TypegetSubType()If the java field is a list/array/map then the sub-type T is returned (ex.java.lang.ClassgetType()java.lang.ObjectgetValue()booleanhasAnnotation(java.lang.Class ann)Indicates whether the annotation is present in the mapping (does not check the java field annotations, just the ones discovered)booleanisSingleValue()voidsetFieldValue(java.lang.Object instance, java.lang.Object val)Sets the value for the java fieldjava.lang.StringtoString()-
Methods inherited from class dev.morphia.mapping.MappedField
addInterestingAnnotation, discover, discoverType, getAnnotation, getAnnotations, getConcreteType, getCTor, getDeclaringClass, getField, getFirstFieldName, getFullName, getJavaFieldName, getLoadNames, getTypeParameters, inferLoadNames, isArray, isMap, isMultipleValues, isReference, isSet, isTransient, isTypeMongoCompatible, putAnnotation, toClass
-
-
-
-
Constructor Detail
-
EphemeralMappedField
public EphemeralMappedField(java.lang.reflect.ParameterizedType t, MappedField mf, Mapper mapper)Creates an EphemeralMappedField.- Parameters:
t- the parameterized type of the fieldmf- the parent MappedFieldmapper- the Mapper to use
-
EphemeralMappedField
public EphemeralMappedField(java.lang.reflect.Type t, MappedField mf, Mapper mapper)Creates an EphemeralMappedField.- Parameters:
t- the type of the fieldmf- the parent MappedFieldmapper- the Mapper to use
-
-
Method Detail
-
addAnnotation
public void addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Description copied from class:MappedFieldAdds the annotation, if it exists on the field.- Overrides:
addAnnotationin classMappedField- Parameters:
clazz- the annotation to add
-
addAnnotation
public void addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz, java.lang.annotation.Annotation ann)Description copied from class:MappedFieldAdds the annotation, if it exists on the field.- Overrides:
addAnnotationin classMappedField- Parameters:
clazz- type of the annotationann- the annotation
-
getDbObjectValue
public java.lang.Object getDbObjectValue(com.mongodb.DBObject dbObj)
- Overrides:
getDbObjectValuein classMappedField- Parameters:
dbObj- the DBObject get the value from- Returns:
- the value from best mapping of this field
-
getFieldValue
public java.lang.Object getFieldValue(java.lang.Object instance)
Description copied from class:MappedFieldGets the value of the field mapped on the instance given.- Overrides:
getFieldValuein classMappedField- Parameters:
instance- the instance to use- Returns:
- the value stored in the java field
-
getMapKeyClass
public java.lang.Class getMapKeyClass()
Description copied from class:MappedFieldIf the underlying java type is a map then it returns T from Map<T,V>- Overrides:
getMapKeyClassin classMappedField- Returns:
- the type of the map key
-
getNameToStore
public java.lang.String getNameToStore()
- Overrides:
getNameToStorein classMappedField- Returns:
- the name of the field's (key)name for mongodb
-
getSubClass
public java.lang.Class getSubClass()
Description copied from class:MappedFieldIf the java field is a list/array/map then the sub-type T is returned (ex. List<T>, T[], Map<?,T>- Overrides:
getSubClassin classMappedField- Returns:
- the parameterized type of the field
-
getSubType
public java.lang.reflect.Type getSubType()
Description copied from class:MappedFieldIf the java field is a list/array/map then the sub-type T is returned (ex. List<T>, T[], Map<?,T>- Overrides:
getSubTypein classMappedField- Returns:
- the parameterized type of the field
-
getType
public java.lang.Class getType()
- Overrides:
getTypein classMappedField- Returns:
- the type of the underlying java field
-
hasAnnotation
public boolean hasAnnotation(java.lang.Class ann)
Description copied from class:MappedFieldIndicates whether the annotation is present in the mapping (does not check the java field annotations, just the ones discovered)- Overrides:
hasAnnotationin classMappedField- Parameters:
ann- the annotation to search for- Returns:
- true if the annotation was found
-
isSingleValue
public boolean isSingleValue()
- Overrides:
isSingleValuein classMappedField- Returns:
- true if this field is not a container type such as a List, Map, Set, or array
-
setFieldValue
public void setFieldValue(java.lang.Object instance, java.lang.Object val)Description copied from class:MappedFieldSets the value for the java field- Overrides:
setFieldValuein classMappedField- Parameters:
instance- the instance to updateval- the value to set
-
toString
public java.lang.String toString()
- Overrides:
toStringin classMappedField
-
getMappedFieldName
public java.lang.String getMappedFieldName()
- Overrides:
getMappedFieldNamein classMappedField- Returns:
- the name of the field's key-name for mongodb
-
getParent
public MappedField getParent()
- Returns:
- the parent MappedField
-
getValue
public java.lang.Object getValue()
- Returns:
- the value of the field
-
-