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

  • 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.
    • andThen

      default BinaryOperator<T> andThen(UnaryOperator<T> after)
    • 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
      Parameters:
      result - the function result
      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.
    • get

      static <T> BinaryOperator<T> get(Supplier<T> supplier)
      Returns a function that returns the value returned by the specified supplier, ignoring its parameter.
      Type Parameters:
      T - the operating type
      Parameters:
      supplier - the function result supplier
      Returns:
      a function that returns the value returned by the specified supplier, ignoring its parameter.
    • 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.