Introduced Collecting façade to support additional collectors.
Collecting.flatcan be used to flat aStreamofIterables, as an example:
Stream.of(Arrays.asList(1, 2, 3), Arrays.asList(4, 5)).collect(Collecting.flat()); // yields [1, 2, 3, 4, 5]
Collecting.reverseuseful 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.batchinunchain(BatchingIterator->UnchainIterator) - renamed
Multiplexing.unchaininunchainShortest(UnchainIterator->UnchainShortestIterator) - renamed
Multiplexing.unchainWithExactChannelSizeinunchainLongest(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 theEitherFunction<Either<LT, RT>, Either<LR, RR>> Eithers::lift(Function<LT, LR> left, Function<RT, RR> right)to lift functions working on the components of anEitherinto 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 anOptionalto aMaybePair<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->FunctionBinaryDelegate->BiFunctionProvider->SupplierPredicate->PredicateBinaryPredicate->BiPredicateAction->ConsumerBinaryAction->BiConsumerProposition->BooleanSupplier
Used java.util.Optional instead of Maybe.
Uniformed named with standard library:
Maybe.fmap->Maybe.mapMaybe.value->Maybe.getMaybe.hasValue->Maybe.isPresentBox.fmap->Box.mapBox.hasContent->Box.isPresentEither.fmap->Either.mapEither.maybe->Either.rightPair.fmap->Pair.mapTriple.fmap->Triple.mapTernaryDelegate->TriFunctionTernaryPredicate->TriPredicate
Removed useless functors:
Identity-> useFunction.identity()orx -> xDropMaybe-> useMaybes::dropEitherToMaybe-> useEithers::rightPureMaybe-> useOptional::ofLiftMaybe-> useOptional::ofNullablePureEither-> useEither::rightPureBox-> useBox::ofMaybeRight-> useEithers::rightMaybeOrElse-> use lambdaMaybeLeft-> useEither::leftMaybeIteratorTransformer-> useMaybeIterator::newIsNothing-> useMaybes::isEmptyIsJust-> useOptional::isPresentFromJust-> useOptional::getFmapMaybe-> invokeMaybes.liftFMapBox-> invokeBoxes.liftFlipEither-> useEither::flipFlipPair-> usePair::flipFlipTriple-> useTriple::flipPairFirst-> usePair::firstPairSecond-> usePair::secondTripleFirst-> useTriple::firstTripleSecond-> useTriple::secondTripleThird-> useTriple::thirdTripleRotateLeft-> useTriple::rotateLeftTripleRotateRight-> useTriple::rotateRightMax-> useBinaryOperator.maxByMin-> useBinaryOperator.minByNegator-> invokepredicate.negate()Equals-> invokePredicate.isEqual()NotEquals-> invokePredicate.isEqual().negate()HasNext-> useIterator::hasNextIteratorPlucker-> useIterable::iteratorClassPlucker-> useObject::getClass