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) applymethod will always returnnull. If a non-nullfunction is passed to this method, it is returned as-is.- Parameters:
func- the function reference (may benull)- Returns:
- a non-
nullobject identical to the passed function, if it is non-null, or a function object always returningnullotherwise
-
safeDefault
public static <R> IntFunction<? extends @Nullable R> safeDefault(@Nullable IntFunction<R> func)
Returns a default function if the argument isnull. The default function'sapplymethod will always returnnull. If a non-nullfunction is passed to this method, it is returned as-is.- Parameters:
func- the function reference (may benull)- Returns:
- a non-
nullobject identical to the passed function, if it is non-null, or a function object always returningnullotherwise
-
safeDefault
public static <R> BiIntFunction<? extends @Nullable R> safeDefault(@Nullable BiIntFunction<R> func)
Returns a default function if the argument isnull. The default function'sapplymethod will always returnnull. If a non-nullfunction is passed to this method, it is returned as-is.- Parameters:
func- the function reference (may benull)- Returns:
- a non-
nullobject identical to the passed function, if it is non-null, or a function object always returningnullotherwise
-
-