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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Accept aTypeas 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:CollectorFactoryAccept aTypeas a collector.- Specified by:
acceptsin 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:CollectorFactoryReturns the element type for a given container type.- Specified by:
elementTypein 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:CollectorFactoryCreates a collector for a given container type.- Specified by:
buildin interfaceCollectorFactory- Parameters:
containerType- the container type.- Returns:
- a
Collectorfor the given container type. - See Also:
-
toOptional
Deprecated.UseOptionalCollectors.toOptional()instead.Returns aCollectorthat accumulates 0 or 1 input elements into anOptional<T>. The returned collector will throwIllegalStateExceptionwhenever 2 or more elements are present in a stream.- Type Parameters:
T- the collected type- Returns:
- a
Collectorwhich 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 aCollectorthat accumulatesMap.Entry<K, V>input elements into a map of the supplied type. The returned collector will throwIllegalStateExceptionwhenever 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- aSupplierwhich returns a new, emptyMapof the appropriate type.- Returns:
- a
Collectorwhich collects map entry elements into aMap, in encounter order.
-