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

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

Go to download

The New JSON Schema prioritizes simplicity, conciseness, and readability, making it user-friendly and accessible without the need for extensive prior knowledge. It offers efficient read-write facilities, precise JSON document definition through various data types and functions, and extensibility to meet modern web service diverse requirements.

There is a newer version: 1.12.1
Show newest version
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