List of utility methods to do Reflection Field Find
Field | findFieldOfBean(Object bean, String fieldName) find Field Of Bean Field field = null; Class<?> clazz = bean.getClass(); while (clazz != null && field == null) { field = findField(clazz.getDeclaredFields(), fieldName); clazz = clazz.getSuperclass(); if (field == null) throw new IllegalStateException("Field " + fieldName + " not found"); ... |
Field | findFieldOfTypeInClass(final Class> source, final Class> type) find Field Of Type In Class for (final Field e : source.getDeclaredFields()) { if (e.getType().equals(type)) { e.setAccessible(true); return e; return null; |
Field | findFieldRecursively(Class> c, String fieldName) find Field Recursively Field f = null; try { f = c.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { if (!c.equals(Object.class)) f = findFieldRecursively(c.getSuperclass(), fieldName); return f; ... |
List | findFields(Class> c, boolean allowTransient, int max, Iterable Find in the given class and all its superclasses all non-static fields assignable to the specified classes to find, except of the specified 'except' classes, and returns such fields as a list. List<Field> result = new ArrayList<Field>(max > 0 && max < 10 ? max : 10); while (c != Object.class && c != null) { for (Field field : c.getDeclaredFields()) { if (Modifier.isStatic(field.getModifiers())) { continue; if (!allowTransient && Modifier.isTransient(field.getModifiers())) { continue; ... |
Map | findFields(Class> type) Loads or fetches from the cache a Map of Field objects keyed into the Map by the field name they correspond to. Map<String, Field> fieldMap; synchronized (fieldCache) { fieldMap = fieldCache.get(type); if (fieldMap != null) { return fieldMap; fieldMap = new HashMap<String, Field>(); Field[] fields = type.getFields(); ... |
List | findFields(final Class> clazz, final Predicate find Fields final List<Field> fields = new ArrayList<>(); collectFields(clazz, filter, fields); fields.forEach(field -> field.setAccessible(true)); return fields; |
Set | findFieldsAnnotatedWith(Class extends Annotation> annotation, Class> parentClass) find Fields Annotated With Set<Field> annotatedFields = new HashSet<Field>(); for (Field field : parentClass.getDeclaredFields()) { if (field.isAnnotationPresent(annotation)) { annotatedFields.add(field); return annotatedFields; |
List | findFieldsAnnotatedWith(final Class> type, final Class extends Annotation> annotation) find Fields Annotated With List<Field> fields = new ArrayList<Field>(); Class<?> klass = type; while (klass != null && klass != Object.class) { final List<Field> allFields = new ArrayList<Field>(Arrays.asList(klass.getDeclaredFields())); for (final Field field : allFields) { if (annotation == null || field.isAnnotationPresent(annotation)) { fields.add(field); klass = klass.getSuperclass(); return fields; |
void | findFieldsOfClass(Class target, Object o, String path, Logger log, Set done) find Fields Of Class if (null == path || path.equals("")) { path = "\nthis"; if (null == done) { done = new HashSet(); if (done.contains(o)) { return; ... |
Field | findFieldToInject(Class> target, String name, Class> source) find Field To Inject Field f = getField(target, name); if (f != null) { Class<?> type = f.getType(); if (type.isAssignableFrom(source) || checkPrimitives(type, source)) { f.setAccessible(true); return f; return null; |