ArrayNode extends Node implements Iterable<Node> { public Optional<Node> get(int index) { return elements.size() > index && index > -1 ? Optional.of(elements.get(index)) : Optional.empty(); } ArrayNode(List<Node> elements, SourceLocation sourceLocation);   ArrayNode(List<Node> elements, SourceLocation sourceLocation, boolean defensiveCopy); @Override Iterator<Node> iterator(); @Override NodeType getType(); @Override R accept(NodeVisitor<R> visitor); @Override ArrayNode expectArrayNode(String errorMessage); @Override Optional<ArrayNode> asArrayNode(); List<Node> getElements(); Optional<Node> get(int index); boolean isEmpty(); int size(); ArrayNode withValue(Node node); List<T> getElementsAs(Class<T> type); @SuppressWarnings("unchecked") List<T> getElementsAs(Function<K, T> f); ArrayNode merge(ArrayNode other); static Collector<T, List<Node>, ArrayNode> collect(); static Collector<T, List<Node>, ArrayNode> collect(SourceLocation sloc); @Override boolean equals(Object other); @Override int hashCode();  }
@Test public void hasGet() { StringNode strNode = Node.from("abc"); ArrayNode node = new ArrayNode(Arrays.asList(strNode), SourceLocation.none()); assertTrue(node.get(0).isPresent()); assertEquals(strNode, node.get(0).get()); assertFalse(node.get(1).isPresent()); }