See: Description
Interface | Description |
---|---|
Fn0<U> |
This is like Java 8's java.util.function.Supplier, but retrofitted to turn checked exceptions
into unchecked ones.
|
Fn1<T,U> |
This is like Java 8's java.util.function.Function, but retrofitted to turn checked exceptions
into unchecked ones.
|
Fn2<A,B,R> |
This is like Java 8's java.util.function.BiFunction, but retrofitted to turn checked exceptions
into unchecked ones.
|
Fn3<A,B,C,R> |
A three-argument, exception-safe functional interface.
|
Class | Description |
---|---|
LazyRef<T> |
Lazily initialize a value (and free the initialization resources) on the first call to get().
|
Enum | Description |
---|---|
Fn1.BooleanCombiner | |
Fn1.ConstObjBool |
Constant functions that take an Object and return a Boolean
|
Fn1.ConstObjObj |
Constant functions that take an Object and return an Object
|
Fn2.Singletons |
Exception-friendly functional interfaces named by the number of arguments: Fn0, Fn1, Fn2....
All of these have an applyEx()
method that that throws an Exception and returns a result.
Implementers should override the applyEx()
method (this happens automatically when you use Java 8's lambda syntax).
Each interface also has a default apply()
method for consumers of this function to call.
It re-throws all exceptions after wrapping any checked ones in unchecked RuntimeException
s.
For simplicity, there are no primitive versions of these functions, no "void" return types, and no special-purpose funny names.
If you don't want to return a result, declare the return type as ?
and return null.
Comparing just the Consumer interfaces from { @link java.util.function}:
java.util.function | org.organicdesign.fp.function |
---|---|
Consumer<T> | Fn1<T,?> |
DoubleConsumer | Fn1<Double,?> |
IntConsumer | Fn1<Integer,?> |
LongConsumer | Fn1<Long,?> |
BiConsumer<T,U> | Fn2<T,U,?> |
ObjDoubleConsumer<T> | Fn2<T,Double,?> |
ObjIntConsumer<T> | Fn2<T,Integer,?> |
ObjLongConsumer<T> | Fn2<T,Long,?> |
Copyright © 2017. All rights reserved.