Package de.caluga.morphium
Klasse AnnotationAndReflectionHelper
java.lang.Object
de.caluga.morphium.AnnotationAndReflectionHelper
User: Stephan Bösebeck
Date: 07.03.13
Time: 11:10
This class will encapsulate all calls to the reflection API. Specially getting all the annotations from
entities is done here. For performance increase (and because the structure of the code usually does not
change during runtime) those results are being cached.
this class is ThreadSafe!
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungAnnotationAndReflectionHelper(boolean convertCamelCase) AnnotationAndReflectionHelper(boolean convertCamelCase, Map<Class<?>, Class<?>> realClassCache) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidcallLifecycleMethod(Class<? extends Annotation> type, Object on) turns documentId into document_idstatic ObjectconvertType(Object value, String fieldName, Class<?> fieldType) createCamelCase(String n, boolean capitalize) converts a sql/javascript-Name to Java, e.g. converts document_id to documentId.getAdditionalDataField(Class<?> cls) getAllAnnotationsFromHierachy(Class<?> cls, Class<? extends Annotation>... anCls) getAllFields(Class clz) return list of fields in class - including hierachy!!!<T extends Annotation>
TgetAnnotationFromClass(Class<?> cls, Class<? extends T> annotationClass) <T extends Annotation>
TgetAnnotationFromHierarchy(Class<?> superClass, Class<? extends T> annotationClass) returns annotations, even if in class hierarchy or lazyloading proxygetClassForTypeId(String typeId) static MethodgetConvertMethod(Class<?> fieldType) getCreationTimeField(Class<?> cls) getDateValue(Object o, String fld) getDoubleValue(Object o, String fld) extended logic: Fld may be, the java field name, the name of the specified value in Property-Annotation or the translated underscored lowercase name (mongoId => mongo_id) or a name specified in the Aliases-Annotation of this fieldgetFields(Class cls, boolean ignoreEntity, Class<? extends Annotation>... annotations) getFields(Class cls, Class<? extends Annotation>... annotations) get a list of valid fields of a given record as they are in the MongoDB so, if you have a field Mapping, the mapped Property-name will be used returns all fields, which have at least one of the given annotations if no annotation is given, all fields are returned Does not take the @Aliases-annotation int accountgetIdField(Object o) getLastAccessField(Class<?> cls) getLastChangeField(Class<?> cls) getLongValue(Object o, String fld) getMongoFieldName(Class clz, String field) get the fieldname used in Mongo for the corresponding field depending on whether camelcase-conversion is enabled globally and whether it is enabled for this specific property also takes "." as path separator into accountgetMongoFieldName(Class clz, String field, boolean ignoreUnknownField) <T> Class<? extends T> getRealClass(Class<? extends T> superClass) <T> TgetRealObject(T o) getStringValue(Object o, String fld) getTypeIdForClass(Class cls) final ClassgetTypeOfField(Class<?> cls, String fld) booleanhasAdditionalData(Class aClass) booleanisAnnotationOnAnyField(Class<?> aClass, Class<? extends Annotation> annotationClass) <T extends Annotation>
booleanisAnnotationPresentInHierarchy(Class<?> aClass, Class<? extends T> annotationClass) booleanisAsyncWrite(Class<?> cls) booleanisBufferedWrite(Class<?> aClass) booleanvoidbooleanstoresCreation(Class<?> cls) booleanstoresLastAccess(Class<?> cls) booleanstoresLastChange(Class<?> cls)
-
Konstruktordetails
-
AnnotationAndReflectionHelper
public AnnotationAndReflectionHelper(boolean convertCamelCase) -
AnnotationAndReflectionHelper
-
-
Methodendetails
-
getTypeIdForClassName
- Löst aus:
ClassNotFoundException
-
getTypeIdForClass
-
getClassForTypeId
- Löst aus:
ClassNotFoundException
-
isAnnotationPresentInHierarchy
public <T extends Annotation> boolean isAnnotationPresentInHierarchy(Class<?> aClass, Class<? extends T> annotationClass) -
isAnnotationOnAnyField
-
getAnnotationFromHierarchy
public <T extends Annotation> T getAnnotationFromHierarchy(Class<?> superClass, Class<? extends T> annotationClass) returns annotations, even if in class hierarchy or lazyloading proxy- Parameter:
superClass- class- Gibt zurück:
- the Annotation
-
getAnnotationFromClass
public <T extends Annotation> T getAnnotationFromClass(Class<?> cls, Class<? extends T> annotationClass) -
getRealClass
-
isBufferedWrite
-
hasAdditionalData
-
getMongoFieldName
get the fieldname used in Mongo for the corresponding field depending on whether camelcase-conversion is enabled globally and whether it is enabled for this specific property also takes "." as path separator into account- Parameter:
clz-field-- Gibt zurück:
-
getMongoFieldName
-
createCamelCase
converts a sql/javascript-Name to Java, e.g. converts document_id to documentId.- Parameter:
n- - string to convertcapitalize- : if true, first letter will be capitalized- Gibt zurück:
- the translated name (capitalized or camel_case => camelCase)
-
convertCamelCase
turns documentId into document_id- Parameter:
n- - string to convert- Gibt zurück:
- converted string (camelCase becomes camel_case)
-
getAllFields
return list of fields in class - including hierachy!!!- Parameter:
clz- class to get all fields for- Gibt zurück:
- list of fields in that class
-
getField
extended logic: Fld may be, the java field name, the name of the specified value in Property-Annotation or the translated underscored lowercase name (mongoId => mongo_id) or a name specified in the Aliases-Annotation of this field- Parameter:
clz- - class to searchfld- - field name- Gibt zurück:
- field, if found, null else
-
isEntity
-
getValue
-
setValue
-
convertType
-
getConvertMethod
-
getId
-
getIdFieldName
-
getIdField
-
getFields
get a list of valid fields of a given record as they are in the MongoDB so, if you have a field Mapping, the mapped Property-name will be used returns all fields, which have at least one of the given annotations if no annotation is given, all fields are returned Does not take the @Aliases-annotation int account- Parameter:
cls- - the class to geht ghe Fields from- Gibt zurück:
- List of Strings, each a field name (as described in @Property or determined by name)
-
getFields
public List<String> getFields(Class cls, boolean ignoreEntity, Class<? extends Annotation>... annotations) -
getRealObject
public <T> T getRealObject(T o) -
getTypeOfField
-
storesLastChange
-
storesLastAccess
-
storesCreation
-
getLongValue
-
getStringValue
-
getDateValue
-
getDoubleValue
-
getAllAnnotationsFromHierachy
public List<Annotation> getAllAnnotationsFromHierachy(Class<?> cls, Class<? extends Annotation>... anCls) -
getLastChangeField
-
getLastAccessField
-
getAdditionalDataField
-
getCreationTimeField
-
callLifecycleMethod
-
isAsyncWrite
-