Introduced Collecting
façade to support additional collectors.
Collecting.flat
can be used to flat aStream
ofIterable
s, as an example:
Stream.of(Arrays.asList(1, 2, 3), Arrays.asList(4, 5)).collect(Collecting.flat()); // yields [1, 2, 3, 4, 5]
Collecting.reverse
useful to invert the order of a finite stream.
Stream.of(1, 2, 3).collect(Collecting.reverse()); // yields [3, 2, 1]
Introduced Strategies
façade with the following methods (:warning: still to test!):
Function<T, R> firstMatch(Clause<T, R>... clauses)
to apply the first clause matching a conditionFunction<T, Optional<R>> maybeFirstMatch(Clause<T, R>... clauses)
to apply optionally the first clause matching a conditionFunction<T, List<R>> allMatches(Clause<T, R>... clauses)
to apply all clauses matching a condition- also for binary functions
Added methods to Maps
class to transform all keys and/or all values of the passed map, given a mapper function:
Map<W, V> mapKeys(Map<K, V> input, Function<K, W> keysMapper)
to transform all keys of the passed map applying the passed mapper functionMap<W, V> mapKeys(Map<K, V> input, Function<K, W> keysMapper, BinaryOperator<V> valueMerger)
to transform all keys of the passed map applying the passed mapper function. If the key is already present into the map, the passed value merger is applied to the valueMap<K, W> mapValues(Map<K, V> input, Function<V, W> valuesMapper)
to transform all values of the passed map applying the passed mapper functionMap<KK, VV> mapKeysAndValues(Map<K, V> input, Function<K, KK> keysMapper, Function<V, VV> valuesMapper)
to transform all keys and all values of the passed map applying the passed mapper functionsMap<KK, VV> mapKeysAndValues(Map<K, V> input, Function<K, KK> keysMapper, Function<V, VV> valuesMapper, BinaryOperator<VV> valueMerger)
to transform all keys and all values of the passed map applying the passed mapper functions. If the key is already present into the map, the passed value merger is applied to the value
Some better names:
- renamed
Multiplexing.batch
inunchain
(BatchingIterator
->UnchainIterator
) - renamed
Multiplexing.unchain
inunchainShortest
(UnchainIterator
->UnchainShortestIterator
) - renamed
Multiplexing.unchainWithExactChannelSize
inunchainLongest
(UnchainWithExactChannelSizeIterator
->UnchainLongestIterator
)
Multiplexing.flatten
and chain
accepts varargs.
Introduced the Sequences
façade, in order to simplify the usage of sequential streams.
A Sequence
has the following additional methods:
- Consumers:
toList
,toSet
,toMap
,first
,maybeFirst
,one
,maybeOne
,last
,maybeLast
,nth
,maybeNth
,at
,maybeAt
- Filtering:
take
,takeLast
,takeAtMostLast
,takeWhile
,drop
,dropWhile
,slice
,distinctBy
- Multiplexing:
chain
- Applications:
tap
Added the following new methods:
Optional<LT> Either::left()
method to get the left part of theEither
Function<Either<LT, RT>, Either<LR, RR>> Eithers::lift(Function<LT, LR> left, Function<RT, RR> right)
to lift functions working on the components of anEither
into a single function working on eitherFunction<Box<T>, Box<R>> Boxes::lift(Function<T, R> function)
to lift a function to another working on box valuesMaybe<T> Maybes::toMaybe(Optional<T> optional)
to convert anOptional
to aMaybe
Pair<T2, T1> Pair::flip()
Triple<T3, T2, T1> Triple::flip()
Triple<T2, T3, T1> Triple::rotateLeft()
Triple<T3, T1, T2> Triple::rotateRight()
Replaced functional interfaces with built-in ones in package java.util.function
:
Delegate
->Function
BinaryDelegate
->BiFunction
Provider
->Supplier
Predicate
->Predicate
BinaryPredicate
->BiPredicate
Action
->Consumer
BinaryAction
->BiConsumer
Proposition
->BooleanSupplier
Used java.util.Optional
instead of Maybe
.
Uniformed named with standard library:
Maybe.fmap
->Maybe.map
Maybe.value
->Maybe.get
Maybe.hasValue
->Maybe.isPresent
Box.fmap
->Box.map
Box.hasContent
->Box.isPresent
Either.fmap
->Either.map
Either.maybe
->Either.right
Pair.fmap
->Pair.map
Triple.fmap
->Triple.map
TernaryDelegate
->TriFunction
TernaryPredicate
->TriPredicate
Removed useless functors:
Identity
-> useFunction.identity()
orx -> x
DropMaybe
-> useMaybes::drop
EitherToMaybe
-> useEithers::right
PureMaybe
-> useOptional::of
LiftMaybe
-> useOptional::ofNullable
PureEither
-> useEither::right
PureBox
-> useBox::of
MaybeRight
-> useEithers::right
MaybeOrElse
-> use lambdaMaybeLeft
-> useEither::left
MaybeIteratorTransformer
-> useMaybeIterator::new
IsNothing
-> useMaybes::isEmpty
IsJust
-> useOptional::isPresent
FromJust
-> useOptional::get
FmapMaybe
-> invokeMaybes.lift
FMapBox
-> invokeBoxes.lift
FlipEither
-> useEither::flip
FlipPair
-> usePair::flip
FlipTriple
-> useTriple::flip
PairFirst
-> usePair::first
PairSecond
-> usePair::second
TripleFirst
-> useTriple::first
TripleSecond
-> useTriple::second
TripleThird
-> useTriple::third
TripleRotateLeft
-> useTriple::rotateLeft
TripleRotateRight
-> useTriple::rotateRight
Max
-> useBinaryOperator.maxBy
Min
-> useBinaryOperator.minBy
Negator
-> invokepredicate.negate()
Equals
-> invokePredicate.isEqual()
NotEquals
-> invokePredicate.isEqual().negate()
HasNext
-> useIterator::hasNext
IteratorPlucker
-> useIterable::iterator
ClassPlucker
-> useObject::getClass