Package dev.morphia.mapping
Class MappedClass
- java.lang.Object
-
- dev.morphia.mapping.MappedClass
-
public class MappedClass extends 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(EntityModel entityModel, Mapper mapper)
Creates a MappedClass instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
callLifecycleMethods(Class<? extends Annotation> event, Object entity, org.bson.Document document, Mapper mapper)
Call the lifecycle methodsboolean
equals(Object o)
<T extends Annotation>
TgetAnnotation(Class<T> clazz)
Looks for an annotation of the type givenString
getCollectionName()
Embedded
getEmbeddedAnnotation()
Entity
getEntityAnnotation()
EntityModel<?>
getEntityModel()
List<MappedField>
getFields()
List<MappedField>
getFields(Class<? extends Annotation> clazz)
Returns fields annotated with the clazzMappedField
getIdField()
MappedField
getMappedField(String storedName)
Returns the MappedField by the name that it will stored in mongodb asMappedField
getMappedFieldByJavaField(String name)
Returns MappedField for a given java field name on the this MappedClassList<MappedClass>
getSubtypes()
MappedClass
getSuperClass()
This is an internal method subject to change without notice.Class<?>
getType()
MappedField
getVersionField()
int
hashCode()
boolean
hasLifecycle(Class<? extends Annotation> type)
Checks if this mapped type has the given lifecycle event definedboolean
isAbstract()
This is an internal method subject to change without notice.boolean
isInterface()
String
toString()
void
update()
Update mappings based on fields/annotations.void
validate(Mapper mapper)
Validates this MappedClass
-
-
-
Constructor Detail
-
MappedClass
public MappedClass(EntityModel entityModel, Mapper mapper)
Creates a MappedClass instance- Parameters:
entityModel
- the ClassModelmapper
- the Mapper to use
-
-
Method Detail
-
getSubtypes
public List<MappedClass> getSubtypes()
- Returns:
- the MappedClasses for all the known subtypes
-
update
public void update()
Update mappings based on fields/annotations.
-
getFields
public List<MappedField> getFields(Class<? extends Annotation> clazz)
Returns fields annotated with the clazz- Parameters:
clazz
- The Annotation to find.- Returns:
- the list of fields
-
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
-
callLifecycleMethods
public void callLifecycleMethods(Class<? extends Annotation> event, Object entity, org.bson.Document document, Mapper mapper)
Call the lifecycle methods- Parameters:
event
- the lifecycle annotationentity
- the entity to processdocument
- the document to usemapper
- the Mapper to use
-
hasLifecycle
public boolean hasLifecycle(Class<? extends Annotation> type)
Checks if this mapped type has the given lifecycle event defined- Parameters:
type
- the event type- Returns:
- true if this annotation has been found
-
getAnnotation
public <T extends Annotation> T getAnnotation(Class<T> clazz)
Looks for an annotation of the type given- Type Parameters:
T
- the annotation type- Parameters:
clazz
- the type to search for- Returns:
- the instance if it was found or null
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getEmbeddedAnnotation
public Embedded getEmbeddedAnnotation()
- Returns:
- the embeddedAn
-
getEntityAnnotation
public Entity getEntityAnnotation()
- Returns:
- the entityAn
-
getIdField
public MappedField getIdField()
- Returns:
- the idField
-
getMappedField
public MappedField getMappedField(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(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
-
getVersionField
public MappedField getVersionField()
- Returns:
- the ID field for the class
-
getFields
public List<MappedField> getFields()
- Returns:
- the fields
-
getType
public Class<?> getType()
- Returns:
- the clazz
-
getCollectionName
public String getCollectionName()
- Returns:
- the collName
-
validate
public void validate(Mapper mapper)
Validates this MappedClass- Parameters:
mapper
- the Mapper to use for validation
-
getEntityModel
public EntityModel<?> getEntityModel()
- Returns:
- the underlying model of the type
-
-