Interface Function3<A,B,C,R>
- Type Parameters:
A- The type of the first argument to the function.B- The type of the second argument to the function.C- The type of the third argument to the function.R- The type of the result of the function.
- All Known Subinterfaces:
ThrowingFunction3<A,B, C, R>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
This interface extends the standard Java Function pattern to support
three-argument functions. It's useful when you need to pass functions with three parameters to methods
that expect functional interfaces, such as in stream operations, builders, or callback patterns.
Features:
- Functional interface - can be used with lambda expressions and method references
- Composition support - provides
andThen(Function)for function chaining - Type-safe - generic type parameters ensure compile-time type safety
Use Cases:
- Three-argument transformations in functional programming patterns
- Builder methods that accept three-parameter functions
- Stream operations requiring three-argument functions
- Callback patterns with three parameters
Usage:
See Also:
Function2- Two-argument functionFunction4- Four-argument functionFunction5- Five-argument function- juneau-commons Basics
-
Method Summary
Modifier and TypeMethodDescriptionReturns a composed function that first applies this function to its input, and then applies theafterfunction to the result.Applies this function to the given arguments.
-
Method Details
-
andThen
Returns a composed function that first applies this function to its input, and then applies theafterfunction to the result.This method enables function composition, allowing you to chain multiple transformations together.
Example:
Function3<Integer,Integer,Integer,Integer>
multiply = (a ,b ,c ) ->a *b *c ; Function3<Integer,Integer,Integer,String>multiplyAndFormat =multiply .andThen(n ->"Result: " +n ); Stringresult =multiplyAndFormat .apply(2, 3, 7);// Returns "Result: 42" - Type Parameters:
V- The type of output of theafterfunction, and of the composed function.- Parameters:
after- The function to apply after this function is applied. Must not benull .- Returns:
- A composed function that first applies this function and then applies the
afterfunction. - Throws:
NullPointerException- ifafterisnull .
-
apply
Applies this function to the given arguments.Example:
Function3<String,Integer,Boolean,String>
repeat = (s ,n ,upper ) -> { Stringresult =s .repeat(n );return upper ?result .toUpperCase() :result ; }; Stringresult =repeat .apply("ha" , 3,true );// Returns "HAHAHA" - Parameters:
a- The first function argument.b- The second function argument.c- The third function argument.- Returns:
- The function result.
-