Package org.apache.tapestry5.json
Class JSONCollectors
- java.lang.Object
- 
- org.apache.tapestry5.json.JSONCollectors
 
- 
 public final class JSONCollectors extends java.lang.Object Implementations ofCollectorthat implement reductions toJSONArrayand toJSONObject.- Since:
- 5.7
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.stream.Collector<T,?,JSONArray>toArray()Returns aCollectorthat accumulates the input elements into a newJSONArray.static <T> java.util.stream.Collector<T,?,JSONObject>toMap(java.util.function.Function<? super T,java.lang.String> keyMapper, java.util.function.Function<? super T,java.lang.Object> valueMapper)Returns aCollectorthat accumulates elements into aJSONObjectwhose keys and values are the result of applying the provided mapping functions to the input elements.
 
- 
- 
- 
Method Detail- 
toArraypublic static <T> java.util.stream.Collector<T,?,JSONArray> toArray() Returns aCollectorthat accumulates the input elements into a newJSONArray.- Type Parameters:
- T- the type of the input elements
- Returns:
- a Collectorwhich collects all the input elements into aJSONArray, in encounter order
- Since:
- 5.7
 
 - 
toMappublic static <T> java.util.stream.Collector<T,?,JSONObject> toMap(java.util.function.Function<? super T,java.lang.String> keyMapper, java.util.function.Function<? super T,java.lang.Object> valueMapper) Returns aCollectorthat accumulates elements into aJSONObjectwhose keys and values are the result of applying the provided mapping functions to the input elements. In case of duplicate keys anIllegalStateExceptionis thrown when the collection operation is performed.- Type Parameters:
- T- the type of the input elements
- Parameters:
- keyMapper- a mapping function to produce String keys
- valueMapper- a mapping function to produce values
- Returns:
- a Collectorwhich collects elements into aJSONObjectwhose keys and values are the result of applying mapping functions to the input elements
- Since:
- 5.7
 
 
- 
 
-