Package org.jdbi.v3.core.collector
Interface CollectorFactory
-
- All Known Implementing Classes:
ArrayCollectorFactory,BuiltInCollectorFactory,EnumSetCollectorFactory,GuavaCollectors.Factory,ListCollectorFactory,MapCollectorFactory,OptionalCollectorFactory,OptionalPrimitiveCollectorFactory,SetCollectorFactory,SimpleCollectorFactory,VavrCollectorFactory
public interface CollectorFactoryFactory for building Collectors to assemble containers of elements. The collector produces only objects of the type of the container elements.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaccepts(java.lang.reflect.Type containerType)Accept aTypeas a collector.java.util.stream.Collector<?,?,?>build(java.lang.reflect.Type containerType)Creates a collector for a given container type.static CollectorFactorycollectorFactory(java.lang.reflect.Type containerType, java.util.stream.Collector<?,?,?> collector)Creates aCollectorFactoryfrom a container type and a collector.static CollectorFactorycollectorFactory(GenericType<?> containerType, java.util.stream.Collector<?,?,?> collector)Creates aCollectorFactoryfrom a parameterized container type and a collector.java.util.Optional<java.lang.reflect.Type>elementType(java.lang.reflect.Type containerType)Returns the element type for a given container type.
-
-
-
Method Detail
-
accepts
boolean accepts(java.lang.reflect.Type containerType)
Accept aTypeas a collector.- Parameters:
containerType- the container type.- Returns:
- whether this factory can produce a collector for the given container type.
-
elementType
java.util.Optional<java.lang.reflect.Type> elementType(java.lang.reflect.Type containerType)
Returns the element type for a given container type.- 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
java.util.stream.Collector<?,?,?> build(java.lang.reflect.Type containerType)
Creates a collector for a given container type.- Parameters:
containerType- the container type.- Returns:
- a
Collectorfor the given container type. - See Also:
StatementContext.findCollectorFor(Type),JdbiCollectors.findFor(Type)
-
collectorFactory
static CollectorFactory collectorFactory(GenericType<?> containerType, java.util.stream.Collector<?,?,?> collector)
Creates aCollectorFactoryfrom a parameterized container type and a collector.- Parameters:
containerType- The parameterized container type that the factory should usecollector- The collector to aassemble container types into a collection- Returns:
- A collection factory instance
- Since:
- 3.38.0
-
collectorFactory
static CollectorFactory collectorFactory(java.lang.reflect.Type containerType, java.util.stream.Collector<?,?,?> collector)
Creates aCollectorFactoryfrom a container type and a collector.- Parameters:
containerType- The container type that the factory should usecollector- The collector to aassemble container types into a collection- Returns:
- A collection factory instance
- Since:
- 3.38.0
-
-