Need help porting some very terse Java code to Xojo

I’m trying to port this Java tutorial to Xojo. I’m struggling to unpack the Set function below because, whilst short and elegant, it crams a lot of conversions into a small space and I’m not sure if I’m understanding it correctly:

public interface GraphNode {
    String getId();

public class Graph<T extends GraphNode> {
    private final Set<T> nodes;
    private final Map<String, Set<String>> connections;

    public T getNode(String id) {
            .filter(node -> node.getId().equals(id))
            .orElseThrow(() -> new IllegalArgumentException("No node found with ID"));

    public Set<T> getConnections(T node) {
        return connections.get(node.getId()).stream()

I basically can only figure what is happening up to the .stream() method call:

  1. Get the Id of the passed node GraphNode
  2. Get the Set<String> from the connections Map whose key matches the retrieved Id

What I don’t understand is what is happening here:


Can someone provide pseudocode to explain this?

not sure where stream comes from as it doesnt seem to be part of Set or Map …

Looks like it’s another interface that is essentially a glorified For...Each loop.

I actually stumbled across an article from May 2003 in xDev Magazine where Joe Strout has written a tutorial doing exactly what I was looking for (an A* pathfinding algorithm). I’ve decided to iterate on his example.