ResourceVisitor { public static <T extends HasMetadata> void visit(T resource, Visitor visitor) { ArrayList<String> path = new ArrayList<>(); try { visit(path, resource, visitor); } catch (RuntimeException | ReflectiveOperationException | StackOverflowError e) { LOGGER.error("Error while visiting {}", path, e); if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new RuntimeException(e); } } }  static void visit(T resource, Visitor visitor);  }
@Test public void testDoesNotThrow() { Kafka k = TestUtils.fromYaml("/example.yaml", Kafka.class, true); assertThat(k, is(notNullValue())); ResourceVisitor.visit(k, new ResourceVisitor.Visitor() { @Override public <M extends AnnotatedElement & Member> void visitProperty(List<String> path, Object owner, M member, ResourceVisitor.Property<M> property, Object propertyValue) { } @Override public void visitObject(List<String> path, Object object) { } }); }
@Test public void testDoesNotThrowWithListenerList() { Kafka k = TestUtils.fromYaml("/example2.yaml", Kafka.class, true); assertThat(k, is(notNullValue())); ResourceVisitor.visit(k, new ResourceVisitor.Visitor() { @Override public <M extends AnnotatedElement & Member> void visitProperty(List<String> path, Object owner, M member, ResourceVisitor.Property<M> property, Object propertyValue) { } @Override public void visitObject(List<String> path, Object object) { } }); }