Class MappedClass


  • public class MappedClass
    extends java.lang.Object
    Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Constructor Summary

      Constructors 
      Constructor Description
      MappedClass​(java.lang.Class<?> clazz, Mapper mapper)
      Creates a MappedClass instance
    • Constructor Detail

      • MappedClass

        public MappedClass​(java.lang.Class<?> clazz,
                           Mapper mapper)
        Creates a MappedClass instance
        Parameters:
        clazz - the class to be mapped
        mapper - the Mapper to use
    • Method Detail

      • getSuperClass

        public MappedClass getSuperClass()
        This is an internal method subject to change without notice.
        Returns:
        the parent class of this type if there is one null otherwise
        Since:
        1.3
      • isInterface

        public boolean isInterface()
        Returns:
        true if the MappedClass is an interface
      • isAbstract

        public boolean isAbstract()
        This is an internal method subject to change without notice.
        Returns:
        true if the MappedClass is abstract
        Since:
        1.3
      • isSupportedType

        public static boolean isSupportedType​(java.lang.Class<?> clazz)
        Checks to see if it a Map/Set/List or a property supported by the MongoDB java driver
        Parameters:
        clazz - the type to check
        Returns:
        true if the type is supported
      • addInterestingAnnotation

        public static void addInterestingAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
        Adds an annotation for Morphia to retain when mapping.
        Parameters:
        annotation - the type to retain
      • addAnnotation

        public void addAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> clazz,
                                  java.lang.annotation.Annotation ann)
        Adds the given Annotation to the internal list for the given Class.
        Parameters:
        clazz - the type to add
        ann - the annotation to add
      • callLifecycleMethods

        public com.mongodb.DBObject callLifecycleMethods​(java.lang.Class<? extends java.lang.annotation.Annotation> event,
                                                         java.lang.Object entity,
                                                         com.mongodb.DBObject dbObj,
                                                         Mapper mapper)
        Call the lifecycle methods
        Parameters:
        event - the lifecycle annotation
        entity - the entity to process
        dbObj - the dbObject to use
        mapper - the Mapper to use
        Returns:
        dbObj
      • containsJavaFieldName

        public boolean containsJavaFieldName​(java.lang.String name)
        Check java field name that will be stored in mongodb
        Parameters:
        name - the name to search for
        Returns:
        true if a Java field with that name is found
      • getAnnotation

        public java.lang.annotation.Annotation getAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
        Looks for an annotation of the type given
        Parameters:
        clazz - the type to search for
        Returns:
        the instance if it was found, if more than one was found, the last one added
      • getAnnotations

        public <T> java.util.List<T> getAnnotations​(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
        Looks for an annotation in the annotations found on a class while mapping
        Type Parameters:
        T - the type of annotation to find
        Parameters:
        clazz - the class to search for
        Returns:
        the instance if it was found, if more than one was found, the last one added
      • getClazz

        public java.lang.Class<?> getClazz()
        Returns:
        the clazz
      • getCollectionName

        public java.lang.String getCollectionName()
        Returns:
        the collName
      • getEmbeddedAnnotation

        public Embedded getEmbeddedAnnotation()
        Returns:
        the embeddedAn
      • getEntityAnnotation

        public Entity getEntityAnnotation()
        Returns:
        the entityAn
      • getFieldsAnnotatedWith

        public java.util.List<MappedField> getFieldsAnnotatedWith​(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
        Returns fields annotated with the clazz
        Parameters:
        clazz - The Annotation to find.
        Returns:
        the list of fields
      • getFirstAnnotation

        public java.lang.annotation.Annotation getFirstAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
        Returns the first found Annotation, or null.
        Parameters:
        clazz - The Annotation to find.
        Returns:
        First found Annotation or null of none found.
      • getIdField

        public java.lang.reflect.Field getIdField()
        Returns:
        the idField
      • getMappedField

        public MappedField getMappedField​(java.lang.String storedName)
        Returns the MappedField by the name that it will stored in mongodb as
        Parameters:
        storedName - the name to search for
        Returns:
        true if that mapped field name is found
      • getMappedFieldByJavaField

        public MappedField getMappedFieldByJavaField​(java.lang.String name)
        Returns MappedField for a given java field name on the this MappedClass
        Parameters:
        name - the Java field name to search for
        Returns:
        the MappedField for the named Java field
      • getMappedIdField

        public MappedField getMappedIdField()
        Returns:
        the ID field for the class
      • getMappedVersionField

        public MappedField getMappedVersionField()
        Returns:
        the ID field for the class
      • getPersistenceFields

        public java.util.List<MappedField> getPersistenceFields()
        Returns:
        the persistenceFields
      • getRelevantAnnotations

        public java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,​java.util.List<java.lang.annotation.Annotation>> getRelevantAnnotations()
        Returns:
        the relevantAnnotations
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • update

        public void update()
        Update mappings based on fields/annotations.
      • validate

        public void validate​(Mapper mapper)
        Validates this MappedClass
        Parameters:
        mapper - the Mapper to use for validation
      • basicValidate

        protected void basicValidate()
      • discover

        protected void discover​(Mapper mapper)
        Discovers interesting (that we care about) things about the class.