示例#1
0
        /// <summary>
        /// Returns a collector that can be used to create a ValueWithFailure instance from a stream of ValueWithFailure
        /// instances.
        /// <para>
        /// The <seealso cref="Collector"/> returned performs a reduction of its <seealso cref="ValueWithFailures"/> input elements under a
        /// specified <seealso cref="BinaryOperator"/> using the provided identity.
        ///
        /// </para>
        /// </summary>
        /// @param <T>  the type of the success value in the <seealso cref="ValueWithFailures"/> </param>
        /// <param name="identityValue">  the identity value </param>
        /// <param name="operator">  the operator used for the reduction. </param>
        /// <returns> a <seealso cref="Collector"/> </returns>
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public static <T> java.util.stream.Collector<ValueWithFailures<T>, ?, ValueWithFailures<T>> toValueWithFailures(T identityValue, java.util.function.BinaryOperator<T> operator)
        public static Collector <ValueWithFailures <T>, ?, ValueWithFailures <T> > toValueWithFailures <T>(T identityValue, System.Func <T, T, T> @operator)
        {
            System.Func <ValueWithFailures <T>, ValueWithFailures <T>, ValueWithFailures <T> > reduceFunction = (result1, result2) => result1.combinedWith(result2, @operator);

            return(Collectors.reducing(ValueWithFailures.of(identityValue), reduceFunction));
        }