Interface QuadFunction<A,B,C,D,R>

Type Parameters:
A - the type of the first argument
B - the type of the second argument
C - the type of the third argument
D - the type of the fourth argument
R - the type of the result
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 QuadFunction<A,B,C,D,R>
Represents a function that accepts four arguments and produces a result.

This is a functional interface extending the concept of Function to support four input parameters. It is useful when you need to pass multiple related values to a single computation.

Example usage:


 // Define a function that calculates area of a rectangle with margins
 QuadFunction<Integer, Integer, Integer, Integer, Integer> areaWithMargins =
     (width, height, marginX, marginY) -> (width - 2*marginX) * (height - 2*marginY);

 // Apply the function
 int result = areaWithMargins.apply(100, 80, 10, 5);  // Returns 5600

 // Chain with another function
 QuadFunction<Integer, Integer, Integer, Integer, String> formatted =
     areaWithMargins.andThen(area -> "Area: " + area + " sq units");
 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default <K> QuadFunction<A,B,C,D,K>
    andThen(Function<? super R,? extends K> after)
    Returns a composed function that first applies this function to its input, and then applies the after function to the result.
    apply(A a, B b, C c, D d)
    Applies this function to the given arguments.
  • Method Details

    • apply

      R apply(A a, B b, C c, D d)
      Applies this function to the given arguments.
      Parameters:
      a - the first function argument
      b - the second function argument
      c - the third function argument
      d - the fourth function argument
      Returns:
      the function result
    • andThen

      default <K> QuadFunction<A,B,C,D,K> andThen(Function<? super R,? extends K> after)
      Returns a composed function that first applies this function to its input, and then applies the after function to the result.

      If evaluation of either function throws an exception, it is relayed to the caller of the composed function.

      Type Parameters:
      K - the type of output of the after function, and of the composed function
      Parameters:
      after - the function to apply after this function is applied
      Returns:
      a composed function that first applies this function and then applies the after function
      Throws:
      NullPointerException - if after is null