Package org.jdbi.v3.core.collector
Class BuiltInCollectorFactory
java.lang.Object
org.jdbi.v3.core.collector.BuiltInCollectorFactory
- All Implemented Interfaces:
CollectorFactory
Deprecated.
will be replaced by plugin
Provides Collectors for built in JDK container types.
Supported container types:
- java.util.Optional<T> (throws an exception if more than one row in result)
- java.util.Collection<T>
- java.util.List<T>
- java.util.ArrayList<T>
- java.util.LinkedList<T>
- java.util.concurrent.CopyOnWriteArrayList<T>
- java.util.Set<T>
- java.util.HashSet<T>
- java.util.LinkedHashSet<T>
- java.util.SortedSet<T>
- java.util.TreeSet<T>
Supported Map types - for rows mapped to Map.Entry<K, V>
- java.util.Map<K, V>
- java.util.HashMap<K, V>
- java.util.LinkedHashMap<K, V>
- java.util.SortedMap<K, V>
- java.util.TreeMap<K, V>
- java.util.concurrent.ConcurrentMap<K, V>
- java.util.concurrent.ConcurrentHashMap<K, V>
- java.util.WeakHashMap<K, V>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Deprecated.Accept aType
as a collector.Collector<?,
?, ?> Deprecated.Creates a collector for a given container type.elementType
(Type containerType) Deprecated.Returns the element type for a given container type.Deprecated.UseMapCollectors.toMap(Supplier)
instead.Deprecated.UseOptionalCollectors.toOptional()
instead.
-
Constructor Details
-
BuiltInCollectorFactory
public BuiltInCollectorFactory()Deprecated.
-
-
Method Details
-
accepts
Deprecated.Description copied from interface:CollectorFactory
Accept aType
as a collector.- Specified by:
accepts
in interfaceCollectorFactory
- Parameters:
containerType
- the container type.- Returns:
- whether this factory can produce a collector for the given container type.
-
elementType
Deprecated.Description copied from interface:CollectorFactory
Returns the element type for a given container type.- Specified by:
elementType
in interfaceCollectorFactory
- Parameters:
containerType
- the container type.- Returns:
- the container element type if it can be discovered through reflection; empty otherwise.
- See Also:
-
build
Deprecated.Description copied from interface:CollectorFactory
Creates a collector for a given container type.- Specified by:
build
in interfaceCollectorFactory
- Parameters:
containerType
- the container type.- Returns:
- a
Collector
for the given container type. - See Also:
-
toOptional
Deprecated.UseOptionalCollectors.toOptional()
instead.Returns aCollector
that accumulates 0 or 1 input elements into anOptional<T>
. The returned collector will throwIllegalStateException
whenever 2 or more elements are present in a stream.- Type Parameters:
T
- the collected type- Returns:
- a
Collector
which collects 0 or 1 input elements into anOptional<T>
.
-
toMap
@Deprecated public static <K,V, Collector<Map.Entry<K,M extends Map<K, V>> V>, toMap?, M> (Supplier<M> mapFactory) Deprecated.UseMapCollectors.toMap(Supplier)
instead.Returns aCollector
that accumulatesMap.Entry<K, V>
input elements into a map of the supplied type. The returned collector will throwIllegalStateException
whenever a set of input elements contains multiple entries with the same key.- Type Parameters:
K
- the type of map keysV
- the type of map valuesM
- the type of the resultingMap
- Parameters:
mapFactory
- aSupplier
which returns a new, emptyMap
of the appropriate type.- Returns:
- a
Collector
which collects map entry elements into aMap
, in encounter order.
-