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

com.bestvike.linq.adapter.enumerator.IteratorEnumerator Maven / Gradle / Ivy

package com.bestvike.linq.adapter.enumerator;

import com.bestvike.linq.enumerable.AbstractEnumerator;

import java.util.Iterator;

/**
 * Created by 许崇雷 on 2019-07-01.
 */
public final class IteratorEnumerator extends AbstractEnumerator {
    private final Iterator source;

    public IteratorEnumerator(Iterator source) {
        this.source = source;
    }

    @Override
    public boolean moveNext() {
        switch (this.state) {
            case 0:
                if (this.source.hasNext()) {
                    this.current = this.source.next();
                    return true;
                }
                this.close();
                return false;
            default:
                return false;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy