public class AnnotationAndReflectionHelper extends Object
this class is ThreadSafe!
| Constructor and Description |
|---|
AnnotationAndReflectionHelper(boolean convertCamelCase) |
AnnotationAndReflectionHelper(boolean convertCamelCase,
Map<Class<?>,Class<?>> realClassCache) |
| Modifier and Type | Method and Description |
|---|---|
void |
callLifecycleMethod(Class<? extends Annotation> type,
Object on) |
String |
convertCamelCase(String n)
turns documentId into document_id
|
String |
createCamelCase(String n,
boolean capitalize)
converts a sql/javascript-Name to Java, e.g. converts document_id to
documentId.
|
String |
getAdditionalDataField(Class<?> cls) |
List<Annotation> |
getAllAnnotationsFromHierachy(Class<?> cls,
Class<? extends Annotation>... anCls) |
List<Field> |
getAllFields(Class clz)
return list of fields in class - including hierachy!!!
|
<T extends Annotation> |
getAnnotationFromHierarchy(Class<?> superClass,
Class<? extends T> annotationClass)
returns annotations, even if in class hierarchy or
lazyloading proxy
|
Class |
getClassForTypeId(String typeId) |
String |
getCreationTimeField(Class<?> cls) |
Date |
getDateValue(Object o,
String fld) |
Double |
getDoubleValue(Object o,
String fld) |
Field |
getField(Class clz,
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 field
|
String |
getFieldName(Class clz,
String field) |
List<String> |
getFields(Class cls,
boolean ignoreEntity,
Class<? extends Annotation>... annotations) |
List<String> |
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 account
|
Object |
getId(Object o) |
Field |
getIdField(Object o) |
String |
getIdFieldName(Object o) |
String |
getLastAccessField(Class<?> cls) |
String |
getLastChangeField(Class<?> cls) |
Long |
getLongValue(Object o,
String fld) |
<T> Class<? extends T> |
getRealClass(Class<? extends T> superClass) |
<T> T |
getRealObject(T o) |
String |
getStringValue(Object o,
String fld) |
String |
getTypeIdForClass(Class cls) |
String |
getTypeIdForClassName(String n) |
Class |
getTypeOfField(Class<?> cls,
String fld) |
Object |
getValue(Object o,
String fld) |
Long |
getVersion(Object o) |
Field |
getVersionField(Object o) |
boolean |
hasAdditionalData(Class aClass) |
<T extends Annotation> |
isAnnotationPresentInHierarchy(Class<?> aClass,
Class<? extends T> annotationClass) |
boolean |
isAsyncWrite(Class<?> cls) |
boolean |
isBufferedWrite(Class<?> aClass) |
boolean |
isEntity(Object o) |
void |
setValue(Object o,
Object value,
String fld) |
boolean |
storesCreation(Class<?> cls) |
boolean |
storesLastAccess(Class<?> cls) |
boolean |
storesLastChange(Class<?> cls) |
public AnnotationAndReflectionHelper(boolean convertCamelCase)
public String getTypeIdForClassName(String n) throws ClassNotFoundException
ClassNotFoundExceptionpublic Class getClassForTypeId(String typeId) throws ClassNotFoundException
ClassNotFoundExceptionpublic <T extends Annotation> boolean isAnnotationPresentInHierarchy(Class<?> aClass, Class<? extends T> annotationClass)
public <T extends Annotation> T getAnnotationFromHierarchy(Class<?> superClass, Class<? extends T> annotationClass)
superClass - classpublic boolean isBufferedWrite(Class<?> aClass)
public boolean hasAdditionalData(Class aClass)
public String createCamelCase(String n, boolean capitalize)
n - - string to convertcapitalize - : if true, first letter will be capitalizedpublic String convertCamelCase(String n)
n - - string to convertpublic List<Field> getAllFields(Class clz)
clz - class to get all fields forpublic Field getField(Class clz, String fld)
clz - - class to searchfld - - field namepublic boolean isEntity(Object o)
public List<String> getFields(Class cls, Class<? extends Annotation>... annotations)
cls - - the class to geht ghe Fields frompublic List<String> getFields(Class cls, boolean ignoreEntity, Class<? extends Annotation>... annotations)
public <T> T getRealObject(T o)
public boolean storesLastChange(Class<?> cls)
public boolean storesLastAccess(Class<?> cls)
public boolean storesCreation(Class<?> cls)
public List<Annotation> getAllAnnotationsFromHierachy(Class<?> cls, Class<? extends Annotation>... anCls)
public void callLifecycleMethod(Class<? extends Annotation> type, Object on)
public boolean isAsyncWrite(Class<?> cls)
Copyright © 2018. All rights reserved.