Class FunctionsUtil
- java.lang.Object
-
- net.automatalib.common.util.function.FunctionsUtil
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,R>
Function<T,? extends @Nullable R>safeDefault(@Nullable Function<T,R> func)
Returns a default function if the argument isnull
.static <R> IntFunction<? extends @Nullable R>
safeDefault(@Nullable IntFunction<R> func)
Returns a default function if the argument isnull
.static <R> BiIntFunction<? extends @Nullable R>
safeDefault(@Nullable BiIntFunction<R> func)
Returns a default function if the argument isnull
.static <T> Predicate<T>
safeToFalse(@Nullable Predicate<T> func)
static <T> Predicate<T>
safeToTrue(@Nullable Predicate<T> func)
-
-
-
Method Detail
-
safeDefault
public static <T,R> Function<T,? extends @Nullable R> safeDefault(@Nullable Function<T,R> func)
Returns a default function if the argument isnull
. The default function'sFunction#apply(Object) apply
method will always returnnull
. If a non-null
function is passed to this method, it is returned as-is.- Parameters:
func
- the function reference (may benull
)- Returns:
- a non-
null
object identical to the passed function, if it is non-null
, or a function object always returningnull
otherwise
-
safeDefault
public static <R> IntFunction<? extends @Nullable R> safeDefault(@Nullable IntFunction<R> func)
Returns a default function if the argument isnull
. The default function'sapply
method will always returnnull
. If a non-null
function is passed to this method, it is returned as-is.- Parameters:
func
- the function reference (may benull
)- Returns:
- a non-
null
object identical to the passed function, if it is non-null
, or a function object always returningnull
otherwise
-
safeDefault
public static <R> BiIntFunction<? extends @Nullable R> safeDefault(@Nullable BiIntFunction<R> func)
Returns a default function if the argument isnull
. The default function'sapply
method will always returnnull
. If a non-null
function is passed to this method, it is returned as-is.- Parameters:
func
- the function reference (may benull
)- Returns:
- a non-
null
object identical to the passed function, if it is non-null
, or a function object always returningnull
otherwise
-
-