AnnotationSearchCriteria implements SearchCriteria { @Override public boolean isSatisfied(Class<?> cls) { return cls.getDeclaredAnnotation(annotation) != null; } AnnotationSearchCriteria(Class<? extends Annotation> annotation); @Override boolean isSatisfied(Class<?> cls);  }
@Test void isSatisfied() { AnnotationSearchCriteria criteria = new AnnotationSearchCriteria(Entity.class); List<Field> fields = Search.getAllFields(AnnotatedClass.class, criteria); assertEquals(0, fields.size()); criteria = new AnnotationSearchCriteria(Entity.class); fields = Search.getAllFields(ChildAnnotatedClass.class, criteria); assertEquals(1, fields.size()); criteria = new AnnotationSearchCriteria(Entity.class); fields = Search.getAllFields(BabyAnnotatedClass.class, criteria); assertEquals(2, fields.size()); SearchCriteria search = criteria; assertThrows(IllegalArgumentException.class, () -> Search.getAllFields(null, search)); assertThrows(IllegalArgumentException.class, () -> Search.getAllFields(BaseClass.class, null)); }