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

com.relogiclabs.json.schema.internal.util.StreamHelper Maven / Gradle / Ivy

package com.relogiclabs.json.schema.internal.util;

import java.util.stream.Stream;

public final class StreamHelper {
    public static  T halt(RuntimeException exception) {
        throw exception;
    }

    public static boolean forEachTrue(Stream stream) {
        // When no short-circuit evaluation with no early return
        boolean result = true;
        for(var r : iterable(stream)) result &= r;
        return result;
    }

    public static  int count(Stream stream) {
        // Java stream count ignore exceptions
        int counter = 0;
        for(var ignored : iterable(stream)) counter++;
        return counter;
    }

    public static  Iterable iterable(Stream stream) {
        return stream::iterator;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy