Interface BiFunction<T,U,R>

Type Parameters:
T - the first parameter type
U - the second parameter type
R - the result type
All Superinterfaces:
BiFunction<T,U,R>
All Known Subinterfaces:
BinaryOperator<T>
All Known Implementing Classes:
BiFunction.FormerIdentityFunction, BiFunction.LatterIdentityFunction, BinaryOperator.FormerIdentityOperator, BinaryOperator.LatterIdentityOperator

public interface BiFunction<T,U,R> extends BiFunction<T,U,R>
An enhanced binary function.
Author:
Paul Ferraro
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
     
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BiFunction<?,?,?>
     
    static final BiFunction<?,?,?>
     
    static final BiFunction<?,?,?>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default <V> BiFunction<T,U,V>
    andThen(Function<? super R,? extends V> after)
     
    default <V1, V2> BiFunction<V1,V2,R>
    compose(Function<? super V1,? extends T> before1, Function<? super V2,? extends U> before2)
    Returns a composed function that applies the specified functions to each parameter as inputs to this function.
    static <T extends R, U, R>
    BiFunction<T,U,R>
    Returns a function that returns its first parameter.
    static <T, U, R> BiFunction<T,U,R>
    former(Function<T,R> function)
    Returns a function that returns the result of applying the specified function to its first parameter.
    static <T, U extends R, R>
    BiFunction<T,U,R>
    Returns a function that returns its second parameter.
    static <T, U, R> BiFunction<T,U,R>
    latter(Function<U,R> function)
    Returns a function that returns the result of applying the specified function to its second parameter.
    static <T, U, R> BiFunction<T,U,R>
    of(Supplier<R> supplier)
    Returns a function that returns the value returned by the specified supplier, ignoring its parameter.
    static <T, U, R> BiFunction<T,U,R>
    of(R result)
    Returns a function that always returns the specified value, ignoring its parameter.
    default BiFunction<T,U,R>
    orDefault(BiPredicate<T,U> predicate, Supplier<R> 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.
    default BiFunction<U,T,R>
    Returns a function that processes this function with reversed parameter order.
    default BiFunction<T,U,R>
    withDefault(Predicate<T> predicate1, Supplier<T> defaultValue1, Predicate<U> predicate2, Supplier<U> 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 java.util.function.BiFunction

    apply
  • Field Details

    • FORMER_IDENTITY

      static final BiFunction<?,?,?> FORMER_IDENTITY
    • LATTER_IDENTITY

      static final BiFunction<?,?,?> LATTER_IDENTITY
    • NULL

      static final BiFunction<?,?,?> NULL
  • Method Details

    • compose

      default <V1, V2> BiFunction<V1,V2,R> compose(Function<? super V1,? extends T> before1, Function<? super V2,? extends U> before2)
      Returns a composed function that applies the specified functions to each parameter as inputs to this function.
      Type Parameters:
      V1 - the first parameter function type
      V2 - the second parameter function type
      Parameters:
      before1 - the function applied to the first parameter
      before2 - the function applied to the second parameter
      Returns:
      a composed function that applies the specified functions to each parameter as inputs to this function.
    • andThen

      default <V> BiFunction<T,U,V> andThen(Function<? super R,? extends V> after)
      Specified by:
      andThen in interface BiFunction<T,U,R>
    • reverse

      default BiFunction<U,T,R> reverse()
      Returns a function that processes this function with reversed parameter order.
      Returns:
      a function that processes this function with reversed parameter order.
    • withDefault

      default BiFunction<T,U,R> withDefault(Predicate<T> predicate1, Supplier<T> defaultValue1, Predicate<U> predicate2, Supplier<U> 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.
      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 BiFunction<T,U,R> orDefault(BiPredicate<T,U> predicate, Supplier<R> 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.
      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 extends R, U, R> BiFunction<T,U,R> former()
      Returns a function that returns its first parameter.
      Type Parameters:
      T - the first parameter type
      U - the second parameter type
      R - the function return type
      Returns:
      a function that returns its first parameter.
    • former

      static <T, U, R> BiFunction<T,U,R> former(Function<T,R> function)
      Returns a function that returns the result of applying the specified function to its first parameter.
      Type Parameters:
      T - the first parameter type
      U - the second parameter type
      R - the function return type
      Parameters:
      function - the function applied to the first parameter of this function
      Returns:
      a function that returns the result of applying the specified function to its first parameter.
    • latter

      static <T, U extends R, R> BiFunction<T,U,R> latter()
      Returns a function that returns its second parameter.
      Type Parameters:
      T - the first parameter type
      U - the second parameter type
      R - the function return type
      Returns:
      a function that returns its first parameter.
    • latter

      static <T, U, R> BiFunction<T,U,R> latter(Function<U,R> function)
      Returns a function that returns the result of applying the specified function to its second parameter.
      Type Parameters:
      T - the first parameter type
      U - the second parameter type
      R - the function return type
      Parameters:
      function - the function applied to the second parameter of this function
      Returns:
      a function that returns the result of applying the specified function to its second parameter.
    • of

      static <T, U, R> BiFunction<T,U,R> of(R result)
      Returns a function that always returns the specified value, ignoring its parameter.
      Type Parameters:
      T - the first parameter type
      U - the second parameter type
      R - the function return type
      Parameters:
      result - the function result
      Returns:
      a function that always returns the specified value, ignoring its parameter.
    • of

      static <T, U, R> BiFunction<T,U,R> of(Supplier<R> supplier)
      Returns a function that returns the value returned by the specified supplier, ignoring its parameter.
      Type Parameters:
      T - the first parameter type
      U - the second parameter type
      R - the function return type
      Parameters:
      supplier - the function result supplier
      Returns:
      a function that returns the value returned by the specified supplier, ignoring its parameter.