/** * This method returns true if the given annotation is present on the given field. * * @param fieldClass * @param fieldName * @param annotation * @return true if the given annotation is present */ public static boolean isAnnotationPresent(Class<?> fieldClass, String fieldName, Class<? extends Annotation> annotation) { ClassFields<?> classFields = ClassDataCacher.getInstance().getClassFields(fieldClass); try { return classFields.getFieldAnnotation(annotation, fieldName) != null; } catch (FieldnameNotFoundException e) { return false; } }
/** * Get the class fields analysis of a class which contains information about that class and its fields, * includes annotations, fields/properties, etc. packaged in a way which makes the data easy to get to, * use the {@link ClassData} object to get to the more raw data * * @param <T> * @param cls any {@link Class} * @return the ClassFields analysis object which contains the information about this class */ public <T> ClassFields<T> getClassFields(Class<T> cls) { return getClassFields(cls, this.fieldFindMode); }
/** * Get the class fields analysis of a class which contains information about that class and its fields, * includes annotations, fields/properties, etc. packaged in a way which makes the data easy to get to, * use the {@link ClassData} object to get to the more raw data * * @param <T> * @param cls any {@link Class} * @return the ClassFields analysis object which contains the information about this class */ public <T> ClassFields<T> getClassFields(Class<T> cls) { return getClassFields(cls, this.fieldFindMode); }
/** * Convenience Method: <br/> * Analyze an object and produce an object which contains information about it and its fields, * see {@link ClassDataCacher#getClassData(Class)} * * @param <T> * @param obj any {@link Object} * @return the ClassFields analysis object which contains the information about this objects class * @throws IllegalArgumentException if obj is null */ @SuppressWarnings("unchecked") public <T> ClassFields<T> getClassFieldsFromObject(Object obj) { if (obj == null) { throw new IllegalArgumentException("obj cannot be null"); } Class<T> cls = (Class<T>) obj.getClass(); return getClassFields(cls); }
/** * Convenience Method: <br/> * Analyze an object and produce an object which contains information about it and its fields, * see {@link ClassDataCacher#getClassData(Class)} * * @param <T> * @param obj any {@link Object} * @return the ClassFields analysis object which contains the information about this objects class * @throws IllegalArgumentException if obj is null */ @SuppressWarnings("unchecked") public <T> ClassFields<T> getClassFieldsFromObject(Object obj) { if (obj == null) { throw new IllegalArgumentException("obj cannot be null"); } Class<T> cls = (Class<T>) obj.getClass(); return getClassFields(cls); }
/** * Analyze a class and produce an object which contains information about it and its fields * @param <T> * @param cls any class * @return the ClassFields analysis object which contains the information about this object class * @throws IllegalArgumentException if class is null or primitive */ public <T> ClassFields<T> analyzeClass(Class<T> cls) { ClassFields<T> cf = getClassDataCacher().getClassFields(cls); return cf; }
/** * Analyze a class and produce an object which contains information about it and its fields * @param <T> * @param cls any class * @return the ClassFields analysis object which contains the information about this object class * @throws IllegalArgumentException if class is null or primitive */ public <T> ClassFields<T> analyzeClass(Class<T> cls) { ClassFields<T> cf = getClassDataCacher().getClassFields(cls); return cf; }
public <T> ClassFields<T> analyzeClass(Class<T> cls, ClassFields.FieldFindMode mode) { ClassFields<T> cf = getClassDataCacher().getClassFields(cls, mode); return cf; }
public <T> ClassFields<T> analyzeClass(Class<T> cls, ClassFields.FieldFindMode mode) { ClassFields<T> cf = getClassDataCacher().getClassFields(cls, mode); return cf; }
/** * Convenience Method: <br/> * Gets the class data object which contains information about this class, * will retrieve this from the class data cache if available or generate it if not<br/> * This is also available from the {@link ClassFields} object * * @param <T> * @param cls any {@link Class} * @return the class data cache object (contains reflected data from this class) */ public <T> ClassData<T> getClassData(Class<T> cls) { ClassFields<T> cf = getClassFields(cls); return cf.getClassData(); }
/** * Convenience Method: <br/> * Gets the class data object which contains information about this class, * will retrieve this from the class data cache if available or generate it if not<br/> * This is also available from the {@link ClassFields} object * * @param <T> * @param cls any {@link Class} * @return the class data cache object (contains reflected data from this class) */ public <T> ClassData<T> getClassData(Class<T> cls) { ClassFields<T> cf = getClassFields(cls); return cf.getClassData(); }