Package org.jdbi.v3.core.collector
Class JdbiCollectors
- java.lang.Object
-
- org.jdbi.v3.core.collector.JdbiCollectors
-
- All Implemented Interfaces:
JdbiConfig<JdbiCollectors>
public class JdbiCollectors extends java.lang.Object implements JdbiConfig<JdbiCollectors>
Registry of collector factories. Contains a set of collector factories, registered by the application.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<CollectorFactory>factoriesprivate java.util.concurrent.ConcurrentMap<java.lang.reflect.Type,java.util.Optional<CollectorFactory>>factoryCache
-
Constructor Summary
Constructors Modifier Constructor Description JdbiCollectors()privateJdbiCollectors(JdbiCollectors that)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JdbiCollectorscreateCopy()Returns a copy of this configuration object.java.util.Optional<java.lang.reflect.Type>findElementTypeFor(java.lang.reflect.Type containerType)Returns the element type for the given container type.private java.util.Optional<CollectorFactory>findFactoryFor(java.lang.reflect.Type containerType)java.util.Optional<java.util.stream.Collector<?,?,?>>findFor(java.lang.reflect.Type containerType)Obtain a collector for the given type.JdbiCollectorsregister(CollectorFactory factory)Register a newCollectorFactory.JdbiCollectorsregisterCollector(java.lang.reflect.Type collectionType, java.util.stream.Collector<?,?,?> collector)Register a newCollectorfor the given type.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jdbi.v3.core.config.JdbiConfig
setRegistry
-
-
-
-
Field Detail
-
factories
private final java.util.List<CollectorFactory> factories
-
factoryCache
private java.util.concurrent.ConcurrentMap<java.lang.reflect.Type,java.util.Optional<CollectorFactory>> factoryCache
-
-
Constructor Detail
-
JdbiCollectors
public JdbiCollectors()
-
JdbiCollectors
private JdbiCollectors(JdbiCollectors that)
-
-
Method Detail
-
register
public JdbiCollectors register(CollectorFactory factory)
Register a newCollectorFactory.- Parameters:
factory- A collector factory- Returns:
- this
-
registerCollector
public JdbiCollectors registerCollector(java.lang.reflect.Type collectionType, java.util.stream.Collector<?,?,?> collector)
Register a newCollectorfor the given type.- Parameters:
collectionType- The type that this collector will returncollector- ACollectorimplementation- Returns:
- this
- Since:
- 3.38.0
- See Also:
Configurable.registerCollector(CollectorFactory)
-
findFor
public java.util.Optional<java.util.stream.Collector<?,?,?>> findFor(java.lang.reflect.Type containerType)
Obtain a collector for the given type.- Parameters:
containerType- the container type.- Returns:
- a Collector for the given container type, or empty null if no collector is registered for the given type.
-
findElementTypeFor
public java.util.Optional<java.lang.reflect.Type> findElementTypeFor(java.lang.reflect.Type containerType)
Returns the element type for the given container type.- Parameters:
containerType- the container type.- Returns:
- the element type for the given container type, if available.
-
findFactoryFor
private java.util.Optional<CollectorFactory> findFactoryFor(java.lang.reflect.Type containerType)
-
createCopy
public JdbiCollectors createCopy()
Description copied from interface:JdbiConfigReturns a copy of this configuration object. Changes to the copy should not modify the original, and vice-versa.- Specified by:
createCopyin interfaceJdbiConfig<JdbiCollectors>- Returns:
- a copy of this configuration object.
-
-