public Iterator iterator()

in asterix-graphix/src/main/java/org/apache/asterix/graphix/lang/rewrite/lower/struct/ClauseCollection.java [163:197]


    public Iterator<AbstractClause> iterator() {
        Iterator<AbstractClause> nonRepresentativeIterator = nonRepresentativeClauses.iterator();
        Iterator<LetClause> representativeVertexIterator = representativeVertexBindings.iterator();
        Iterator<LetClause> representativeEdgeIterator = representativeEdgeBindings.iterator();
        Iterator<LetClause> representativePathIterator = representativePathBindings.iterator();
        Iterator<AbstractBinaryCorrelateClause> userCorrelateIterator = userCorrelateClauses.iterator();
        return new Iterator<>() {
            @Override
            public boolean hasNext() {
                return nonRepresentativeIterator.hasNext() || representativeVertexIterator.hasNext()
                        || representativeEdgeIterator.hasNext() || representativePathIterator.hasNext()
                        || userCorrelateIterator.hasNext();
            }

            @Override
            public AbstractClause next() {
                if (nonRepresentativeIterator.hasNext()) {
                    return nonRepresentativeIterator.next();
                }
                if (representativeVertexIterator.hasNext()) {
                    return representativeVertexIterator.next();
                }
                if (representativeEdgeIterator.hasNext()) {
                    return representativeEdgeIterator.next();
                }
                if (representativePathIterator.hasNext()) {
                    return representativePathIterator.next();
                }
                if (userCorrelateIterator.hasNext()) {
                    return userCorrelateIterator.next();
                }
                throw new IllegalStateException();
            }
        };
    }