Class EntityModel


  • public class EntityModel
    extends Object
    A model of metadata about a type
    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 Detail

      • callLifecycleMethods

        public void callLifecycleMethods​(Class<? extends Annotation> event,
                                         Object entity,
                                         org.bson.Document document,
                                         Mapper mapper)
        Invokes any lifecycle methods
        Parameters:
        event - the event to run
        entity - the entity to use
        document - the document used in persistence
        mapper - the mapper to use
      • getAnnotation

        @Nullable
        public <A extends Annotation> A getAnnotation​(Class<A> clazz)
        Type Parameters:
        A - the annotation type
        Parameters:
        clazz - the annotation class
        Returns:
        the annotation instance or null if not found
      • getAnnotations

        public Map<Class<? extends Annotation>,​Annotation> getAnnotations()
        Returns all the annotations on this model
        Returns:
        the list of annotations
      • getCollectionName

        public String getCollectionName()
        Returns:
        the mapped collection name for the type
      • getDiscriminator

        public String getDiscriminator()
        Returns:
        the discriminator
      • getDiscriminatorKey

        public String getDiscriminatorKey()
        Returns:
        the discriminator key
      • getEmbeddedAnnotation

        @Nullable
        public Embedded getEmbeddedAnnotation()
        Returns:
        the embeddedAn
      • getEntityAnnotation

        @Nullable
        public Entity getEntityAnnotation()
        Returns:
        the entityAn
      • getIdProperty

        @Nullable
        public PropertyModel getIdProperty()
        Returns:
        the model for the id property
      • getProperties

        public List<PropertyModel> getProperties​(Class<? extends Annotation> type)
        Returns all the properties on this model annotated by the given type
        Parameters:
        type - the annotation type
        Returns:
        the list of properties
      • getProperties

        public List<PropertyModel> getProperties()
        Returns all the properties on this model
        Returns:
        the list of properties
      • getProperty

        @Nullable
        public PropertyModel getProperty​(@Nullable
                                         String name)
        Parameters:
        name - the property name
        Returns:
        the named PropertyModel or null if it does not exist
      • getInstanceCreator

        public MorphiaInstanceCreator getInstanceCreator()
        Returns:
        a new InstanceCreator instance for the ClassModel
      • getInstanceCreatorFactory

        public InstanceCreatorFactory getInstanceCreatorFactory()
        Returns:
        thee creator factory
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getName

        public String getName()
        Returns:
        the name of this model
      • getSubtypes

        public List<EntityModel> getSubtypes()
        Get the subtypes of this model
        Returns:
        the subtypes
      • getSuperClass

        @Nullable
        public EntityModel getSuperClass()
        Returns:
        the model of the superclass of this type or null
      • getType

        public Class<?> getType()
        Returns:
        the type of this model
      • getVersionProperty

        @Nullable
        public PropertyModel getVersionProperty()
        Returns:
        the version property for the class
      • hasLifecycle

        public boolean hasLifecycle​(Class<? extends Annotation> type)
        Parameters:
        type - the lifecycle event type
        Returns:
        true if that even has been configured
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isAbstract

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

        public boolean isInterface()
        Returns:
        true if the EntityModel is an interface
      • useDiscriminator

        public boolean useDiscriminator()
        Returns:
        true if the discriminator should be used
        Since:
        2.2.7
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.