Class EntityModel<T>

  • Type Parameters:
    T - the entity type

    public class EntityModel<T>
    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

        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 <A extends Annotation> A getAnnotations​(Class<A> clazz)
        Type Parameters:
        A - the annotation type
        Parameters:
        clazz - the annotation class
        Returns:
        the annotation instance of the given type
      • 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
      • getFieldModelByName

        public FieldModel<?> getFieldModelByName​(String name)
        Parameters:
        name - the property name
        Returns:
        the named FieldModel or null if it does not exist
      • getFieldModels

        public Collection<FieldModel<?>> getFieldModels()
        Returns all the fields on this model
        Returns:
        the list of fields
      • getIdModel

        public FieldModel<?> getIdModel()
        Returns:
        the model for the id field
      • getInstanceCreator

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

        public InstanceCreatorFactory<T> 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
      • getType

        public Class<T> getType()
        Returns:
        the type of this model
      • 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
      • useDiscriminator

        protected boolean useDiscriminator()