Interface BiFunction<T1,T2,R,E extends Exception>

Type Parameters:
T1 - the type of the input to the function
T2 - the type of the input to the function
R - the type of the result of the function
E - the type of the exception that may be thrown
All Known Subinterfaces:
BinaryOperator<T,E>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface BiFunction<T1,T2,R,E extends Exception>
Represents a function that accepts two arguments, produces a result and (optionally) throws an Exception.

This is a functional interface whose functional method is apply(Object, Object) )}.

Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(T1 t, T2 t2)
    Applies this function to the given argument.
    Lifts this function that may throw an exception into a function that returns an Optional.
    static <T1, T2, R>
    BiFunction<T1,T2,Optional<R>>
    lifted(BiFunction<? super T1,? super T2,? extends R,?> function)
    Lifts a function that may throw an exception into a function that returns an Optional.
    default BiFunction<T1,T2,R>
    Wraps this function that may throw an exception into a function that will throw a RuntimeException if the original function throws an exception.
    static <T1, T2, R>
    BiFunction<T1,T2,R>
    unchecked(BiFunction<? super T1,? super T2,? extends R,?> function)
    Wraps a function that may throw an exception into a function that will throw a RuntimeException if the original function throws an exception.
  • Method Details

    • apply

      R apply(T1 t, T2 t2) throws E
      Applies this function to the given argument.
      Parameters:
      t - the first function argument
      t2 - the second function argument
      Returns:
      the function result
      Throws:
      E - if an exception occurs
      Since:
      1.0
    • lifted

      static <T1, T2, R> BiFunction<T1,T2,Optional<R>> lifted(BiFunction<? super T1,? super T2,? extends R,?> function)
      Lifts a function that may throw an exception into a function that returns an Optional. If the original function throws an exception, the returned function will return an empty Optional. Otherwise, the returned function will return an Optional containing the result of the original function.
      Type Parameters:
      T1 - the type of the first input to the function
      T2 - the type of the second input to the function
      R - the type of the result of the function
      Parameters:
      function - the function to lift
      Returns:
      a function that returns an Optional
      Since:
      1.0
    • unchecked

      static <T1, T2, R> BiFunction<T1,T2,R> unchecked(BiFunction<? super T1,? super T2,? extends R,?> function)
      Wraps a function that may throw an exception into a function that will throw a RuntimeException if the original function throws an exception.
      Type Parameters:
      T1 - the type of the first input to the function
      T2 - the type of the second input to the function
      R - the type of the result of the function
      Parameters:
      function - the function to wrap
      Returns:
      a function that will throw a RuntimeException if the original function throws an exception
      Since:
      1.0
    • lift

      default BiFunction<T1,T2,Optional<R>> lift()
      Lifts this function that may throw an exception into a function that returns an Optional. If the original function throws an exception, the returned function will return an empty Optional. Otherwise, the returned function will return an Optional containing the result of the original function.
      Returns:
      a function that returns an Optional
      Since:
      1.0
      See Also:
    • unchecked

      default BiFunction<T1,T2,R> unchecked()
      Wraps this function that may throw an exception into a function that will throw a RuntimeException if the original function throws an exception.
      Returns:
      a function that will throw a RuntimeException if the original function throws an exception
      Since:
      1.0
      See Also: