Interface BinaryOperator<T>

Type Parameters:
T - the operator type
All Superinterfaces:
BiFunction<T,T,T>, BiFunction<T,T,T>, BinaryOperator<T>

public interface BinaryOperator<T> extends BinaryOperator<T>, BiFunction<T,T,T>
An enhanced binary function.
Author:
Paul Ferraro
  • Field Details

    • FORMER_IDENTITY

      static final BinaryOperator<?> FORMER_IDENTITY
      An identity function using the former parameter
    • LATTER_IDENTITY

      static final BinaryOperator<?> LATTER_IDENTITY
      An identity function using the latter parameter
    • NULL

      static final BinaryOperator<?> NULL
      An operator that always returns null.
  • Method Details

    • compose

      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.
      Parameters:
      before1 - the operator applied to the first parameter
      before2 - 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

      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.
      Parameters:
      before1 - the operator applied to the first parameter
      before2 - 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

      default BinaryOperator<T> andThen(UnaryOperator<T> after)
      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

      default BinaryOperator<T> reverse()
      Returns a function that processes this function with reversed parameter order.
      Specified by:
      reverse in interface BiFunction<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:
      withDefault in interface BiFunction<T,T,T>
      Parameters:
      predicate1 - a predicate used to determine the first parameter of this function
      defaultValue1 - a provider of the default value of the first parameter
      predicate2 - a predicate used to determine the second parameter of this function
      defaultValue2 - 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

      default BinaryOperator<T> orDefault(BiPredicate<T,T> predicate, Supplier<T> defaultResult)
      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:
      orDefault in interface BiFunction<T,T,T>
      Parameters:
      predicate - a predicate used to determine the parameter of this function
      defaultResult - 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

      static <T> BinaryOperator<T> former()
      Returns a function that returns its first parameter.
      Type Parameters:
      T - the operating type
      Returns:
      a function that returns its first parameter.
    • latter

      static <T> BinaryOperator<T> latter()
      Returns a function that returns its second parameter.
      Type Parameters:
      T - the operating type
      Returns:
      a function that returns its first parameter.
    • empty

      static <T> BinaryOperator<T> 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

      static <T> BinaryOperator<T> of(T result)
      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

      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.
      Type Parameters:
      T - the operator type
      Parameters:
      consumer - the consumer of the function parameter
      supplier - 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

      static <T> BinaryOperator<T> apply(BiFunction<? super T, ? super T, T> function)
      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

      static <T> BinaryOperator<T> applyFormer(UnaryOperator<T> operator)
      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

      static <T> BinaryOperator<T> applyLatter(UnaryOperator<T> operator)
      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.