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

org.infinispan.commons.dataconversion.internal.JsonUtils Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev04
Show newest version
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());
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy