@Test public void testRetrieveMixedAnnotatedFields() { Field[] fields = mRetriever.getFields(TestModels.MixedPublicFields.class); assertNotNull(fields); assertThat(fields, FieldMatcher.haveNames("b")); }
public Field[] getFields(@NonNull Class<?> cls) { Field[] cachedFields = mCachedFields.get(cls); if (cachedFields != null) return cachedFields; Class<?> currentClass = cls; final List<Field> futureCachedFields = new LinkedList<>(); do { Field[] declaredFields = currentClass.getDeclaredFields(); for (int i = 0; i < currentClass.getDeclaredFields().length; i++) { final Field field = declaredFields[i]; final Annotation annotation = field.getAnnotation(SaveState.class); if (annotation == null) continue; futureCachedFields.add(field); } } while ((currentClass = currentClass.getSuperclass()) != null); cachedFields = futureCachedFields.toArray(new Field[futureCachedFields.size()]); mCachedFields.put(cls, cachedFields); return cachedFields; }
DefaultFieldsRetriever implements FieldsRetriever { public Field[] getFields(@NonNull Class<?> cls) { Field[] cachedFields = mCachedFields.get(cls); if (cachedFields != null) return cachedFields; Class<?> currentClass = cls; final List<Field> futureCachedFields = new LinkedList<>(); do { Field[] declaredFields = currentClass.getDeclaredFields(); for (int i = 0; i < currentClass.getDeclaredFields().length; i++) { final Field field = declaredFields[i]; final Annotation annotation = field.getAnnotation(SaveState.class); if (annotation == null) continue; futureCachedFields.add(field); } } while ((currentClass = currentClass.getSuperclass()) != null); cachedFields = futureCachedFields.toArray(new Field[futureCachedFields.size()]); mCachedFields.put(cls, cachedFields); return cachedFields; } }
DefaultFieldsRetriever implements FieldsRetriever { public Field[] getFields(@NonNull Class<?> cls) { Field[] cachedFields = mCachedFields.get(cls); if (cachedFields != null) return cachedFields; Class<?> currentClass = cls; final List<Field> futureCachedFields = new LinkedList<>(); do { Field[] declaredFields = currentClass.getDeclaredFields(); for (int i = 0; i < currentClass.getDeclaredFields().length; i++) { final Field field = declaredFields[i]; final Annotation annotation = field.getAnnotation(SaveState.class); if (annotation == null) continue; futureCachedFields.add(field); } } while ((currentClass = currentClass.getSuperclass()) != null); cachedFields = futureCachedFields.toArray(new Field[futureCachedFields.size()]); mCachedFields.put(cls, cachedFields); return cachedFields; } DefaultFieldsRetriever(); }
DefaultFieldsRetriever implements FieldsRetriever { public Field[] getFields(@NonNull Class<?> cls) { Field[] cachedFields = mCachedFields.get(cls); if (cachedFields != null) return cachedFields; Class<?> currentClass = cls; final List<Field> futureCachedFields = new LinkedList<>(); do { Field[] declaredFields = currentClass.getDeclaredFields(); for (int i = 0; i < currentClass.getDeclaredFields().length; i++) { final Field field = declaredFields[i]; final Annotation annotation = field.getAnnotation(SaveState.class); if (annotation == null) continue; futureCachedFields.add(field); } } while ((currentClass = currentClass.getSuperclass()) != null); cachedFields = futureCachedFields.toArray(new Field[futureCachedFields.size()]); mCachedFields.put(cls, cachedFields); return cachedFields; } DefaultFieldsRetriever(); Field[] getFields(@NonNull Class<?> cls); }
DefaultFieldsRetriever implements FieldsRetriever { public Field[] getFields(@NonNull Class<?> cls) { Field[] cachedFields = mCachedFields.get(cls); if (cachedFields != null) return cachedFields; Class<?> currentClass = cls; final List<Field> futureCachedFields = new LinkedList<>(); do { Field[] declaredFields = currentClass.getDeclaredFields(); for (int i = 0; i < currentClass.getDeclaredFields().length; i++) { final Field field = declaredFields[i]; final Annotation annotation = field.getAnnotation(SaveState.class); if (annotation == null) continue; futureCachedFields.add(field); } } while ((currentClass = currentClass.getSuperclass()) != null); cachedFields = futureCachedFields.toArray(new Field[futureCachedFields.size()]); mCachedFields.put(cls, cachedFields); return cachedFields; } DefaultFieldsRetriever(); Field[] getFields(@NonNull Class<?> cls);  }