org.infinispan.commons.dataconversion.internal.JsonUtils Maven / Gradle / Ivy
package org.infinispan.commons.dataconversion.internal;
import java.util.Collection;
import java.util.function.Function;
import java.util.stream.Stream;
/**
* Utility function for {@link Json}
*
* @author Pedro Ruivo
* @since 13.0
*/
public final class JsonUtils {
private JsonUtils() {
}
public static Json createJsonArray(Collection collection) {
return createJsonArray(collection, Json::make);
}
public static Json createJsonArray(Stream stream) {
return createJsonArray(stream, Json::make);
}
public static Json createJsonArray(Collection collection, Function jsonFactory) {
return createJsonArray(collection.stream(), jsonFactory);
}
public static Json createJsonArray(Stream stream, Function jsonFactory) {
return stream.map(jsonFactory).collect(new JsonArrayCollector());
}
}