All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.annimon.stream.operator.ObjConcat Maven / Gradle / Ivy

The newest version!
package com.annimon.stream.operator;

import com.annimon.stream.iterator.LsaExtIterator;
import java.util.Iterator;

public class ObjConcat extends LsaExtIterator {

    private final Iterator iterator1;
    private final Iterator iterator2;
    private boolean firstStreamIsCurrent;

    public ObjConcat(Iterator iterator1, Iterator iterator2) {
        this.iterator1 = iterator1;
        this.iterator2 = iterator2;
        firstStreamIsCurrent = true;
    }

    @Override
    protected void nextIteration() {
        if (firstStreamIsCurrent) {
            if (iterator1.hasNext()) {
                next = iterator1.next();
                hasNext = true;
                return;
            }
            firstStreamIsCurrent = false;
        }
        if (iterator2.hasNext()) {
            next = iterator2.next();
            hasNext = true;
            return;
        }
        hasNext = false;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy