Class MappedField


  • public class MappedField
    extends Object
    Developer note.
    This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Method Detail

      • getMappedFieldName

        public String getMappedFieldName()
        Returns:
        the name of the field's (key)name for mongodb
      • hasAnnotation

        public boolean hasAnnotation​(Class ann)
        Indicates whether the annotation is present in the mapping (does not check the java field annotations, just the ones discovered)
        Parameters:
        ann - the annotation to search for
        Returns:
        true if the annotation was found
      • getDeclaringClass

        public MappedClass getDeclaringClass()
        Returns:
        the declaring class of the java field
      • getField

        public Field getField()
        Returns:
        the underlying java field
      • getDocumentValue

        public Object getDocumentValue​(org.bson.Document document)
        Parameters:
        document - the Document get the value from
        Returns:
        the value from first mapping of this field
      • getLoadNames

        public List<String> getLoadNames()
        Returns:
        the name of the field's (key)name for mongodb, in order of loading.
      • getFullName

        public String getFullName()
        Returns:
        the full name of the class plus java field name
      • getFieldValue

        public Object getFieldValue​(Object instance)
        Gets the value of the field mapped on the instance given.
        Parameters:
        instance - the instance to use
        Returns:
        the value stored in the java field
      • getJavaFieldName

        public String getJavaFieldName()
        Returns:
        the name of the java field, as declared on the class
      • getSpecializedType

        public Class getSpecializedType()
        If the java field is a list/array/map then the sub-type T is returned (ex. List, T[], Map
        Returns:
        the parameterized type of the field
      • getType

        public Class getType()
        Returns:
        the type of the underlying java field
      • isTransient

        public boolean isTransient()
        Returns:
        true if this field is marked as transient
      • isMultipleValues

        public boolean isMultipleValues()
        Returns:
        true if this field is a container type such as a List, Map, Set, or array
      • isScalarValue

        public boolean isScalarValue()
        Returns:
        true if this field is not a container type such as a List, Map, Set, or array
      • isMap

        public boolean isMap()
        Returns:
        true if the MappedField is a Map
      • isArray

        public boolean isArray()
        Returns:
        true if the MappedField is an array
      • getTypeData

        public org.bson.codecs.pojo.TypeData<?> getTypeData()
        Returns:
        the field's type data
      • isReference

        public boolean isReference()
        Returns:
        true if this field is a reference to a foreign document
        See Also:
        Reference, Key, DBRef
      • getAnnotation

        public <T extends Annotation> T getAnnotation​(Class<T> clazz)
        Type Parameters:
        T - the type of the annotation
        Parameters:
        clazz - the annotation to search for
        Returns:
        the annotation instance if it exists on this field
      • isSet

        public boolean isSet()
        Returns:
        true if the MappedField is a Set
      • setFieldValue

        public void setFieldValue​(Object instance,
                                  Object value)
        Sets the value for the java field
        Parameters:
        instance - the instance to update
        value - the value to set
      • getNormalizedType

        public Class getNormalizedType()
        Gets the parameterized type of a List or the key type of a Map, e.g.
        Returns:
        the unwrapped type
      • getFieldModel

        public FieldModel getFieldModel()
        Returns:
        the underlying field model
      • inferLoadNames

        protected List<String> inferLoadNames()