Class 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 Detail

      • EphemeralMappedField

        public EphemeralMappedField​(java.lang.reflect.ParameterizedType t,
                                    MappedField mf,
                                    Mapper mapper)
        Creates an EphemeralMappedField.
        Parameters:
        t - the parameterized type of the field
        mf - the parent MappedField
        mapper - 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 field
        mf - the parent MappedField
        mapper - the Mapper to use
    • Method Detail

      • addAnnotation

        public void addAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
        Description copied from class: MappedField
        Adds the annotation, if it exists on the field.
        Overrides:
        addAnnotation in class MappedField
        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: MappedField
        Adds the annotation, if it exists on the field.
        Overrides:
        addAnnotation in class MappedField
        Parameters:
        clazz - type of the annotation
        ann - the annotation
      • getDbObjectValue

        public java.lang.Object getDbObjectValue​(com.mongodb.DBObject dbObj)
        Overrides:
        getDbObjectValue in class MappedField
        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: MappedField
        Gets the value of the field mapped on the instance given.
        Overrides:
        getFieldValue in class MappedField
        Parameters:
        instance - the instance to use
        Returns:
        the value stored in the java field
      • getMapKeyClass

        public java.lang.Class getMapKeyClass()
        Description copied from class: MappedField
        If the underlying java type is a map then it returns T from Map<T,V>
        Overrides:
        getMapKeyClass in class MappedField
        Returns:
        the type of the map key
      • getNameToStore

        public java.lang.String getNameToStore()
        Overrides:
        getNameToStore in class MappedField
        Returns:
        the name of the field's (key)name for mongodb
      • getSubClass

        public java.lang.Class getSubClass()
        Description copied from class: MappedField
        If the java field is a list/array/map then the sub-type T is returned (ex. List<T>, T[], Map<?,T>
        Overrides:
        getSubClass in class MappedField
        Returns:
        the parameterized type of the field
      • getSubType

        public java.lang.reflect.Type getSubType()
        Description copied from class: MappedField
        If the java field is a list/array/map then the sub-type T is returned (ex. List<T>, T[], Map<?,T>
        Overrides:
        getSubType in class MappedField
        Returns:
        the parameterized type of the field
      • getType

        public java.lang.Class getType()
        Overrides:
        getType in class MappedField
        Returns:
        the type of the underlying java field
      • hasAnnotation

        public boolean hasAnnotation​(java.lang.Class ann)
        Description copied from class: MappedField
        Indicates whether the annotation is present in the mapping (does not check the java field annotations, just the ones discovered)
        Overrides:
        hasAnnotation in class MappedField
        Parameters:
        ann - the annotation to search for
        Returns:
        true if the annotation was found
      • isSingleValue

        public boolean isSingleValue()
        Overrides:
        isSingleValue in class MappedField
        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: MappedField
        Sets the value for the java field
        Overrides:
        setFieldValue in class MappedField
        Parameters:
        instance - the instance to update
        val - the value to set
      • getMappedFieldName

        public java.lang.String getMappedFieldName()
        Overrides:
        getMappedFieldName in class MappedField
        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