Package org.jdbi.v3.core.collector
Class BuiltInCollectorFactory
- java.lang.Object
-
- org.jdbi.v3.core.collector.BuiltInCollectorFactory
-
- All Implemented Interfaces:
CollectorFactory
@Deprecated public class BuiltInCollectorFactory extends java.lang.Object implements CollectorFactory
Deprecated.will be replaced by pluginProvides 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>
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<CollectorFactory>FACTORIESDeprecated.
-
Constructor Summary
Constructors Constructor Description BuiltInCollectorFactory()Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanaccepts(java.lang.reflect.Type containerType)Deprecated.Accept aTypeas a collector.java.util.stream.Collector<?,?,?>build(java.lang.reflect.Type containerType)Deprecated.Creates a collector for a given container type.private static <K,V,M extends java.util.Map<K,V>>
Mcombine(M a, M b)Deprecated.java.util.Optional<java.lang.reflect.Type>elementType(java.lang.reflect.Type containerType)Deprecated.Returns the element type for a given container type.private static <K,V,M extends java.util.Map<K,V>>
voidputEntry(M map, java.util.Map.Entry<K,V> entry)Deprecated.private static <K,V,M extends java.util.Map<K,V>>
voidputEntry(M map, K key, V value)Deprecated.static <K,V,M extends java.util.Map<K,V>>
java.util.stream.Collector<java.util.Map.Entry<K,V>,?,M>toMap(java.util.function.Supplier<M> mapFactory)Deprecated.UseMapCollectors.toMap(Supplier)instead.static <T> java.util.stream.Collector<T,?,java.util.Optional<T>>toOptional()Deprecated.UseOptionalCollectors.toOptional()instead.
-
-
-
Field Detail
-
FACTORIES
private static final java.util.List<CollectorFactory> FACTORIES
Deprecated.
-
-
Method Detail
-
accepts
public boolean accepts(java.lang.reflect.Type containerType)
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
public java.util.Optional<java.lang.reflect.Type> elementType(java.lang.reflect.Type containerType)
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:
StatementContext.findElementTypeFor(Type)
-
build
public java.util.stream.Collector<?,?,?> build(java.lang.reflect.Type containerType)
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:
StatementContext.findCollectorFor(Type),JdbiCollectors.findFor(Type)
-
toOptional
@Deprecated public static <T> java.util.stream.Collector<T,?,java.util.Optional<T>> 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,M extends java.util.Map<K,V>> java.util.stream.Collector<java.util.Map.Entry<K,V>,?,M> toMap(java.util.function.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.
-
putEntry
private static <K,V,M extends java.util.Map<K,V>> void putEntry(M map, java.util.Map.Entry<K,V> entry)Deprecated.
-
putEntry
private static <K,V,M extends java.util.Map<K,V>> void putEntry(M map, K key, V value)Deprecated.
-
combine
private static <K,V,M extends java.util.Map<K,V>> M combine(M a, M b)Deprecated.
-
-