
com.relogiclabs.json.schema.internal.util.StreamHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of relogiclabs-json-schema Show documentation
Show all versions of relogiclabs-json-schema Show documentation
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.
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