public class BuiltInCollectorFactory extends Object implements CollectorFactory
Supported container types:
Supported Map types - for rows mapped to Map.Entry<K, V>
| Constructor and Description |
|---|
BuiltInCollectorFactory() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accepts(Type containerType) |
Collector<?,?,?> |
build(Type containerType) |
Optional<Type> |
elementType(Type containerType) |
static <K,V,M extends Map<K,V>> |
toMap(Supplier<M> mapFactory)
Returns a
Collector that accumulates Map.Entry<K, V> input elements into a
map of the supplied type. |
static <T> Collector<T,?,Optional<T>> |
toOptional()
Returns a
Collector that accumulates 0 or 1 input elements into an Optional<T>. |
public boolean accepts(Type containerType)
accepts in interface CollectorFactorycontainerType - the container typepublic Collector<?,?,?> build(Type containerType)
build in interface CollectorFactorycontainerType - the type of the containerCollector for the given container type.StatementContext.findCollectorFor(Type),
JdbiCollectors.findFor(Type)public Optional<Type> elementType(Type containerType)
elementType in interface CollectorFactorycontainerType - the container typeStatementContext.findElementTypeFor(Type)public static <K,V,M extends Map<K,V>> Collector<Map.Entry<K,V>,?,M> toMap(Supplier<M> mapFactory)
Collector that accumulates Map.Entry<K, V> input elements into a
map of the supplied type. The returned collector will throw IllegalStateException
whenever a set of input elements contains multiple entries with the same key.K - the type of map keysV - the type of map valuesM - the type of the resulting MapmapFactory - a Supplier which returns a new, empty Map of the appropriate type.Collector which collects map entry elements into a Map, in encounter order.public static <T> Collector<T,?,Optional<T>> toOptional()
Collector that accumulates 0 or 1 input elements into an Optional<T>.
The returned collector will throw IllegalStateException whenever 2 or more elements
are present in a stream.T - the collected typeCollector which collects 0 or 1 input elements into an Optional<T>.Copyright © 2017. All rights reserved.