public class AnnotationAndReflectionHelper extends Object
| Constructor and Description |
|---|
AnnotationAndReflectionHelper() |
| 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.
|
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<?> cls,
Class<? extends T> anCls)
returns annotations, even if in class hierarchy or
lazyloading proxy
|
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,
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
|
org.bson.types.ObjectId |
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> sc) |
<T> T |
getRealObject(T o) |
String |
getStringValue(Object o,
String fld) |
Class |
getTypeOfField(Class<?> cls,
String fld) |
Object |
getValue(Object o,
String fld) |
boolean |
hasAdditionalData(Class clz) |
<T extends Annotation> |
isAnnotationPresentInHierarchy(Class<?> cls,
Class<? extends T> anCls) |
boolean |
isBufferedWrite(Class<?> cls) |
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 <T extends Annotation> boolean isAnnotationPresentInHierarchy(Class<?> cls, Class<? extends T> anCls)
public boolean isBufferedWrite(Class<?> cls)
public <T extends Annotation> T getAnnotationFromHierarchy(Class<?> cls, Class<? extends T> anCls)
cls - classpublic boolean hasAdditionalData(Class clz)
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 org.bson.types.ObjectId getId(Object o)
public List<String> getFields(Class cls, Class<? extends Annotation>... annotations)
cls - 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)
Copyright © 2013. All Rights Reserved.