AttributeAxisIterator implements Iterator<Attribute> { public AttributeAxisIterator(Node contextNode) { this.node = contextNode; if (!METHOD_CACHE.containsKey(contextNode.getClass())) { Method[] preFilter = contextNode.getClass().getMethods(); List<MethodWrapper> postFilter = new ArrayList<>(); for (Method element : preFilter) { if (isAttributeAccessor(element)) { postFilter.add(new MethodWrapper(element)); } } METHOD_CACHE.putIfAbsent(contextNode.getClass(), postFilter.toArray(new MethodWrapper[0])); } this.methodWrappers = METHOD_CACHE.get(contextNode.getClass()); this.position = 0; this.currObj = getNextAttribute(); } AttributeAxisIterator(Node contextNode); @Override Attribute next(); @Override boolean hasNext(); @Override void remove();  }
@Test public void testAttributeAxisIterator() { DummyNode dummyNode = new DummyNode(1); dummyNode.testingOnlySetBeginLine(1); dummyNode.testingOnlySetBeginColumn(1); AttributeAxisIterator it = new AttributeAxisIterator(dummyNode); Map<String, Attribute> atts = toMap(it); Assert.assertEquals(7, atts.size()); assertTrue(atts.containsKey("BeginColumn")); assertTrue(atts.containsKey("BeginLine")); assertTrue(atts.containsKey("FindBoundary")); assertTrue(atts.containsKey("Image")); assertTrue(atts.containsKey("SingleLine")); assertTrue(atts.containsKey("EndColumn")); assertTrue(atts.containsKey("EndLine")); }