Package org.jdbi.v3.core.collector
Class OptionalCollectors
- java.lang.Object
-
- org.jdbi.v3.core.collector.OptionalCollectors
-
public class OptionalCollectors extends java.lang.ObjectFactory methods forcollectorsof optional types.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateOptionalCollectors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.stream.Collector<T,?,java.util.Optional<T>>toOptional()Returns aCollectorthat accumulates 0 or 1 input elements into anOptional<T>.static <T,O>
java.util.stream.Collector<T,?,O>toOptional(java.util.function.Supplier<O> empty, java.util.function.Function<T,O> factory)Returns aCollectorthat accumulates 0 or 1 input elements into an arbitrary optional-style container type.static java.util.stream.Collector<java.lang.Double,?,java.util.OptionalDouble>toOptionalDouble()Returns aCollectorthat accumulates 0 or 1 inputDoubleelements into anOptionalDouble.static java.util.stream.Collector<java.lang.Integer,?,java.util.OptionalInt>toOptionalInt()Returns aCollectorthat accumulates 0 or 1 inputIntegerelements into anOptionalInt.static java.util.stream.Collector<java.lang.Long,?,java.util.OptionalLong>toOptionalLong()Returns aCollectorthat accumulates 0 or 1 inputLongelements into anOptionalLong.
-
-
-
Method Detail
-
toOptional
public static <T> java.util.stream.Collector<T,?,java.util.Optional<T>> toOptional()
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. Null elements are mapped toOptional.empty().- Type Parameters:
T- the collected type- Returns:
- a
Collectorwhich collects 0 or 1 input elements into anOptional<T>.
-
toOptionalInt
public static java.util.stream.Collector<java.lang.Integer,?,java.util.OptionalInt> toOptionalInt()
Returns aCollectorthat accumulates 0 or 1 inputIntegerelements into anOptionalInt. The returned collector will throwIllegalStateExceptionwhenever 2 or more elements are present in a stream. Null elements are mapped toOptionalInt.empty().- Returns:
- a
Collectorwhich collects 0 or 1 inputIntegerelements into anOptionalInt.
-
toOptionalLong
public static java.util.stream.Collector<java.lang.Long,?,java.util.OptionalLong> toOptionalLong()
Returns aCollectorthat accumulates 0 or 1 inputLongelements into anOptionalLong. The returned collector will throwIllegalStateExceptionwhenever 2 or more elements are present in a stream. Null elements are mapped toOptionalLong.empty().- Returns:
- a
Collectorwhich collects 0 or 1 inputLongelements into anOptionalLong.
-
toOptionalDouble
public static java.util.stream.Collector<java.lang.Double,?,java.util.OptionalDouble> toOptionalDouble()
Returns aCollectorthat accumulates 0 or 1 inputDoubleelements into anOptionalDouble. The returned collector will throwIllegalStateExceptionwhenever 2 or more elements are present in a stream. Null elements are mapped toOptionalDouble.empty().- Returns:
- a
Collectorwhich collects 0 or 1 inputDoubleelements into anOptionalDouble.
-
toOptional
public static <T,O> java.util.stream.Collector<T,?,O> toOptional(java.util.function.Supplier<O> empty, java.util.function.Function<T,O> factory)Returns aCollectorthat accumulates 0 or 1 input elements into an arbitrary optional-style container type. The returned collector will throwIllegalStateExceptionwhenever 2 or more elements are present in a stream. Null elements are mapped to an empty container.- Type Parameters:
T- The optional element type.O- The optional type, which may incorporate theTgeneric parameter e.g.Optional<T>.- Parameters:
empty- Supplies an instance of the optional type with no value.factory- Returns an instance of the optional type with the input parameter as the value.- Returns:
- a
Collectorwhich collects 0 or 1 input elements into an arbitrary optional-style container type.
-
-