Interface BinaryOperator<T>
- Type Parameters:
T- the operator type
- All Superinterfaces:
BiFunction<T,T, T>, BiFunction<T, T, T>, BinaryOperator<T>
An enhanced binary function.
- Author:
- Paul Ferraro
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BinaryOperator<?> An identity function using the former parameterstatic final BinaryOperator<?> An identity function using the latter parameterstatic final BinaryOperator<?> An operator that always returns null. -
Method Summary
Modifier and TypeMethodDescriptiondefault BinaryOperator<T> andThen(UnaryOperator<T> after) An operator variant ofBiFunction.andThen(java.util.function.Function).static <T> BinaryOperator<T> apply(BiFunction<? super T, ? super T, T> function) Returns an operator view of the specified binary function.static <T> BinaryOperator<T> applyFormer(UnaryOperator<T> operator) Returns an operator that applies the former parameter to the specified operator.static <T> BinaryOperator<T> applyLatter(UnaryOperator<T> operator) Returns an operator that applies the latter parameter to the specified operator.default BinaryOperator<T> compose(UnaryOperator<T> before1, UnaryOperator<T> before2) Returns a composed operator that applies the specified operators to each parameter as inputs to this operator.default UnaryOperator<T> composeUnary(UnaryOperator<T> before1, UnaryOperator<T> before2) Returns a composed operator that applies the specified operators to each parameter as inputs to this operator.static <T> BinaryOperator<T> empty()Returns a function that always returns null, ignoring its parameter.static <T> BinaryOperator<T> former()Returns a function that returns its first parameter.static <T> BinaryOperator<T> latter()Returns a function that returns its second parameter.static <T> BinaryOperator<T> of(BiConsumer<T, T> consumer, Supplier<T> supplier) Returns an operator that accepts its parameters via the specified consumer and returns the value returned by the specified supplier.static <T> BinaryOperator<T> of(T result) Returns a function that always returns the specified value, ignoring its parameter.default BinaryOperator<T> Returns a function that applies this function if its parameters matches the specified predicate, or returns the value provided by the specified supplier otherwise.default BinaryOperator<T> reverse()Returns a function that processes this function with reversed parameter order.default BinaryOperator<T> withDefault(Predicate<T> predicate1, Supplier<T> defaultValue1, Predicate<T> predicate2, Supplier<T> defaultValue2) Returns a function that applies this function to the values returned by the specified providers if its parameters do not match the specified predicates.Methods inherited from interface BiFunction
applyMethods inherited from interface BiFunction
andThen, compose, composeUnary
-
Field Details
-
FORMER_IDENTITY
An identity function using the former parameter -
LATTER_IDENTITY
An identity function using the latter parameter -
NULL
An operator that always returns null.
-
-
Method Details
-
compose
Returns a composed operator that applies the specified operators to each parameter as inputs to this operator.- Parameters:
before1- the operator applied to the first parameterbefore2- the operator applied to the second parameter- Returns:
- a composed operator that applies the specified operators to each parameter as inputs to this operator.
-
composeUnary
Returns a composed operator that applies the specified operators to each parameter as inputs to this operator.- Parameters:
before1- the operator applied to the first parameterbefore2- the operator applied to the second parameter- Returns:
- a composed operator that applies the specified operators to each parameter as inputs to this operator.
-
andThen
An operator variant ofBiFunction.andThen(java.util.function.Function).- Parameters:
after- the operator to invoke using the result of this operator.- Returns:
- a binary operator that invokes the specified operator using the result of this operator.
-
reverse
Returns a function that processes this function with reversed parameter order.- Specified by:
reversein interfaceBiFunction<T,T, T> - Returns:
- a function that processes this function with reversed parameter order.
-
withDefault
default BinaryOperator<T> withDefault(Predicate<T> predicate1, Supplier<T> defaultValue1, Predicate<T> predicate2, Supplier<T> defaultValue2) Returns a function that applies this function to the values returned by the specified providers if its parameters do not match the specified predicates.- Specified by:
withDefaultin interfaceBiFunction<T,T, T> - Parameters:
predicate1- a predicate used to determine the first parameter of this functiondefaultValue1- a provider of the default value of the first parameterpredicate2- a predicate used to determine the second parameter of this functiondefaultValue2- a provider of the default value of the second parameter- Returns:
- a function that applies this function to the value returned by the specified provider if its value does not match the specified predicate.
-
orDefault
Returns a function that applies this function if its parameters matches the specified predicate, or returns the value provided by the specified supplier otherwise.- Specified by:
orDefaultin interfaceBiFunction<T,T, T> - Parameters:
predicate- a predicate used to determine the parameter of this functiondefaultResult- a provider of the default parameter value- Returns:
- a function that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.
-
former
Returns a function that returns its first parameter.- Type Parameters:
T- the operating type- Returns:
- a function that returns its first parameter.
-
latter
Returns a function that returns its second parameter.- Type Parameters:
T- the operating type- Returns:
- a function that returns its first parameter.
-
empty
Returns a function that always returns null, ignoring its parameter.- Type Parameters:
T- the operating type- Returns:
- a function that always returns null, ignoring its parameter.
-
of
Returns a function that always returns the specified value, ignoring its parameter.- Type Parameters:
T- the operating type- Parameters:
result- the function result- Returns:
- a function that always returns the specified value, ignoring its parameter.
-
of
Returns an operator that accepts its parameters via the specified consumer and returns the value returned by the specified supplier.- Type Parameters:
T- the operator type- Parameters:
consumer- the consumer of the function parametersupplier- the supplier of the function result- Returns:
- an operator that accepts its parameters via the specified consumer and returns the value returned by the specified supplier.
-
apply
Returns an operator view of the specified binary function.- Type Parameters:
T- the operating type- Parameters:
function- the delegating function- Returns:
- an operator view of the specified function.
-
applyFormer
Returns an operator that applies the former parameter to the specified operator.- Type Parameters:
T- the operating type- Parameters:
operator- the operator applied to the former parameter- Returns:
- an operator that applies the former parameter to the specified operator.
-
applyLatter
Returns an operator that applies the latter parameter to the specified operator.- Type Parameters:
T- the operating type- Parameters:
operator- the operator applied to the latter parameter- Returns:
- an operator that applies the latter parameter to the specified operator.
-