Package utility.function
Class Dummy
java.lang.Object
utility.function.Dummy
A utility class to help create dummy stub functional interfaces
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,U> BiConsumer <T, U> Creates a dummy consumerstatic <T,U> BiPredicate <T, U> Creates a dummyBiPredicatethat always returns true.static Callbackcallback()Creates a dummy callbackstatic <T> Consumer<T> consumer()Creates a dummy consumerstatic <T,R> Function <T, R> function()Creates a dummy functionstatic RunnableReturns the given runnable object if it is notnull.static <T,U> BiConsumer <T, U> ifNull(BiConsumer<T, U> c) Returns the given consumer object if it is notnull.static <T,U> BiPredicate <T, U> ifNull(BiPredicate<T, U> p) Returns the given BiPredicate object if it is notnull.static <T> Consumer<T> Returns the given consumer object if it is notnull.static <T,R> Function <T, R> Returns the given function object if it is notnull.static <T> Predicate<T> Returns the given Predicate object if it is notnull.static <T> Supplier<T> Returns the given callback object if it is notnull.static CallbackReturns the given callback object if it is notnull.static <T> Predicate<T> Creates a dummyPredicatethat always returns true.static Runnablerunnable()Creates a dummy runnablestatic <T> Supplier<T> supplier()Creates a dummy supplier
-
Constructor Details
-
Dummy
public Dummy()
-
-
Method Details
-
callback
Creates a dummy callback- Returns:
- a dummy callback
-
consumer
Creates a dummy consumer- Returns:
- a dummy consumer
-
biConsumer
Creates a dummy consumer- Returns:
- a dummy consumer
-
function
Creates a dummy function- Type Parameters:
T- the input typeR- the result type- Returns:
- the function
-
supplier
Creates a dummy supplier- Type Parameters:
T- the result type- Returns:
- the supplier
-
runnable
Creates a dummy runnable- Returns:
- the runnable
-
predicate
Creates a dummyPredicatethat always returns true.- Type Parameters:
T- the type of the value being tested- Returns:
- the predicate that always returns true
-
biPredicate
Creates a dummyBiPredicatethat always returns true.- Type Parameters:
T- the type of the first argument to the predicateU- the type of the second argument the predicate- Returns:
- the BiPredicate that always returns true
-
ifNull
Returns the given consumer object if it is notnull. Otherwise, aconsumer()is returned. This is useful to avoid usingnull.- Parameters:
c- the consumer function to check fornull- Returns:
- a non-null consumer
-
ifNull
Returns the given consumer object if it is notnull. Otherwise, abiConsumer()is returned. This is useful to avoid usingnull.- Parameters:
c- the consumer function to check fornull- Returns:
- a non-null consumer
-
ifNull
Returns the given callback object if it is notnull. Otherwise, acallback()is returned. This is useful to avoid usingnull.- Parameters:
c- the callback function to check fornull- Returns:
- a non-null callback function
-
ifNull
Returns the given function object if it is notnull. Otherwise, afunction()is returned. This is useful to avoid usingnull.- Type Parameters:
T- the input typeR- the result type- Parameters:
f- the function to check fornull- Returns:
- a non-null function
-
ifNull
Returns the given callback object if it is notnull. Otherwise, acallback()is returned. This is useful to avoid usingnull.- Parameters:
s- the supplier function to check fornull- Returns:
- a non-null supplier
-
ifNull
Returns the given runnable object if it is notnull. Otherwise, arunnable()is returned. This is useful to avoid usingnull.- Parameters:
r- the runnable function to check fornull- Returns:
- a non-null runnable
-
ifNull
Returns the given Predicate object if it is notnull. Otherwise, apredicate()(which always returns true) is returned. This is useful to avoid usingnull.- Parameters:
p- the predicate function to check fornull- Returns:
- a non-null predicate
-
ifNull
Returns the given BiPredicate object if it is notnull. Otherwise, abiPredicate()(which always returns true) is returned. This is useful to avoid usingnull.- Parameters:
p- the predicate function to check fornull- Returns:
- a non-null predicate
-