ArrayNode extends Node implements Iterable<Node> { public <T extends Node> List<T> getElementsAs(Class<T> type) { return getElementsAs(type::cast); } 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 failsToGetValuesAsClass() { Assertions.assertThrows(ExpectationNotMetException.class, () -> { Node.fromStrings("a", "b", "c").getElementsAs(NumberNode.class); }); }
@Test public void failsToGetValuesUsingMapper() { Assertions.assertThrows(ExpectationNotMetException.class, () -> { Node.fromStrings("a", "b", "c").getElementsAs(BooleanNode::getValue); }); }