// Path: src/main/java/io/taciturn/Utility.java
// public static <Item> ClassUtility<Item> $(Class<Item> object) {
//     return new ClassUtility<>(object);
// }


import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.Spliterator;
import java.util.Vector;
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.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.BaseStream;
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;
import static io.taciturn.Utility.$;
package io.taciturn.utility;



@SuppressWarnings("WeakerAccess")
public class StreamUtility<Item> extends AbstractUtility<Stream<Item>> {

    public StreamUtility(Stream<Item> object) {
        super(object);
    }

    public boolean allMatch(Predicate<? super Item> predicate) {
        return map(s -> s.allMatch(predicate)).orElse(BooleanUtility.DEFAULT_VALUE);
    }

    public boolean anyMatch(Predicate<? super Item> predicate) {
        return map(s -> s.anyMatch(predicate)).orElse(BooleanUtility.DEFAULT_VALUE);
    }

    public void close() {
        ifPresent(BaseStream::close);
    }

    public <R, A> AbstractUtility<R> collect(Collector<? super Item, A, R> collector) {
        return map(s -> s.collect(collector));
    }

    public <R> AbstractUtility<R> collect(Supplier<R> supplier,
                                          BiConsumer<R, ? super Item> accumulator,
                                          BiConsumer<R, R> combiner) {
        return map(s -> s.collect(supplier, accumulator, combiner));
    }

    public long count() {
        return map(Stream::count).orElse(LongUtility.DEFAULT_VALUE);
    }

    public StreamUtility<Item> distinct() {
// Path: src/main/java/io/taciturn/Utility.java
// public static <Item> ClassUtility<Item> $(Class<Item> object) {
//     return new ClassUtility<>(object);
// }


// Path: src/main/java/io/taciturn/utility/StreamUtility.java
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.Spliterator;
import java.util.Vector;
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.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.BaseStream;
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;
import static io.taciturn.Utility.$;

package io.taciturn.utility;



@SuppressWarnings("WeakerAccess")
public class StreamUtility<Item> extends AbstractUtility<Stream<Item>> {

    public StreamUtility(Stream<Item> object) {
        super(object);
    }

    public boolean allMatch(Predicate<? super Item> predicate) {
        return map(s -> s.allMatch(predicate)).orElse(BooleanUtility.DEFAULT_VALUE);
    }

    public boolean anyMatch(Predicate<? super Item> predicate) {
        return map(s -> s.anyMatch(predicate)).orElse(BooleanUtility.DEFAULT_VALUE);
    }

    public void close() {
        ifPresent(BaseStream::close);
    }

    public <R, A> AbstractUtility<R> collect(Collector<? super Item, A, R> collector) {
        return map(s -> s.collect(collector));
    }

    public <R> AbstractUtility<R> collect(Supplier<R> supplier,
                                          BiConsumer<R, ? super Item> accumulator,
                                          BiConsumer<R, R> combiner) {
        return map(s -> s.collect(supplier, accumulator, combiner));
    }

    public long count() {
        return map(Stream::count).orElse(LongUtility.DEFAULT_VALUE);
    }

    public StreamUtility<Item> distinct() {
        return $(map(Stream::distinct).orElse(null));