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

org.jooq.lambda.SeqImpl Maven / Gradle / Ivy

Go to download

jOOλ is part of the jOOQ series (along with jOOQ, jOOX, jOOR, jOOU) providing some useful extensions to Java 8 lambdas.

There is a newer version: 0.9.15
Show newest version
/**
 * Copyright (c) 2014-2015, Data Geekery GmbH, [email protected]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jooq.lambda;

import java.util.Comparator;
import java.util.Iterator;
import java.util.Optional;
import java.util.Spliterator;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;
import java.util.stream.Collector;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;

/**
 * @author Lukas Eder
 */
class SeqImpl implements Seq {

    private final Stream stream;
    static final Object NULL = new Object();

    SeqImpl(Stream stream) {
        this.stream = stream;
    }

    @Override
    public Stream stream() {
        return stream;
    }

    @Override
    public Seq filter(Predicate predicate) {
        return Seq.seq(stream.filter(predicate));
    }

    @Override
    public  Seq map(Function mapper) {
        return Seq.seq(stream.map(mapper));
    }

    @Override
    public IntStream mapToInt(ToIntFunction mapper) {
        return stream.mapToInt(mapper);
    }

    @Override
    public LongStream mapToLong(ToLongFunction mapper) {
        return stream.mapToLong(mapper);
    }

    @Override
    public DoubleStream mapToDouble(ToDoubleFunction mapper) {
        return stream.mapToDouble(mapper);
    }

    @Override
    public  Seq flatMap(Function> mapper) {
        return Seq.seq(stream.flatMap(mapper));
    }

    @Override
    public IntStream flatMapToInt(Function mapper) {
        return stream.flatMapToInt(mapper);
    }

    @Override
    public LongStream flatMapToLong(Function mapper) {
        return stream.flatMapToLong(mapper);
    }

    @Override
    public DoubleStream flatMapToDouble(Function mapper) {
        return stream.flatMapToDouble(mapper);
    }

    @Override
    public Seq distinct() {
        return Seq.seq(stream.distinct());
    }

    @Override
    public Seq sorted() {
        return Seq.seq(stream.sorted());
    }

    @Override
    public Seq sorted(Comparator comparator) {
        return Seq.seq(stream.sorted(comparator));
    }

    @Override
    public Seq peek(Consumer action) {
        return Seq.seq(stream.peek(action));
    }

    @Override
    public Seq limit(long maxSize) {
        return Seq.seq(stream.limit(maxSize));
    }

    @Override
    public Seq skip(long n) {
        return Seq.seq(stream.skip(n));
    }

    @Override
    public void forEach(Consumer action) {
        stream.forEach(action);
    }

    @Override
    public void forEachOrdered(Consumer action) {
        stream.forEachOrdered(action);
    }

    @Override
    public Object[] toArray() {
        return stream.toArray();
    }

    @Override
    public  A[] toArray(IntFunction generator) {
        return stream.toArray(generator);
    }

    @Override
    public T reduce(T identity, BinaryOperator accumulator) {
        return stream.reduce(identity, accumulator);
    }

    @Override
    public Optional reduce(BinaryOperator accumulator) {
        return stream.reduce(accumulator);
    }

    @Override
    public  U reduce(U identity, BiFunction accumulator, BinaryOperator combiner) {
        return stream.reduce(identity, accumulator, combiner);
    }

    @Override
    public  R collect(Supplier supplier, BiConsumer accumulator, BiConsumer combiner) {
        return stream.collect(supplier, accumulator, combiner);
    }

    @Override
    public  R collect(Collector collector) {
        return stream.collect(collector);
    }

    @Override
    public Optional min(Comparator comparator) {
        return stream.min(comparator);
    }

    @Override
    public Optional max(Comparator comparator) {
        return stream.max(comparator);
    }

    @Override
    public long count() {
        return stream.count();
    }

    @Override
    public boolean anyMatch(Predicate predicate) {
        return stream.anyMatch(predicate);
    }

    @Override
    public boolean allMatch(Predicate predicate) {
        return stream.allMatch(predicate);
    }

    @Override
    public boolean noneMatch(Predicate predicate) {
        return stream.noneMatch(predicate);
    }

    @Override
    public Optional findFirst() {
        return stream.findFirst();
    }

    @Override
    public Optional findAny() {
        return stream.findAny();
    }

    @Override
    public Iterator iterator() {
        return stream.iterator();
    }

    @Override
    public Spliterator spliterator() {
        return stream.spliterator();
    }

    @Override
    public boolean isParallel() {
        return false;
    }

    @Override
    public Seq onClose(Runnable closeHandler) {
        return Seq.seq(stream.onClose(closeHandler));
    }

    @Override
    public void close() {
        stream.close();
    }

    @Override
    public String toString() {
        return Seq.toString(this);
    }
}