Package utility.function
Class Dummy
- java.lang.Object
-
- utility.function.Dummy
-
public class Dummy extends java.lang.Object
A utility class to help create dummy stub functional interfaces
-
-
Constructor Summary
Constructors Constructor Description Dummy()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Callback
callback()
Creates a dummy callbackstatic <T> java.util.function.Consumer<T>
consumer()
Creates a dummy consumerstatic <T,R>
java.util.function.Function<T,R>function()
Creates a dummy functionstatic java.lang.Runnable
ifNull(java.lang.Runnable r)
Returns the given runnable object if it is notnull
.static <T> java.util.function.Consumer<T>
ifNull(java.util.function.Consumer<T> c)
Returns the given consumer object if it is notnull
.static <T,R>
java.util.function.Function<T,R>ifNull(java.util.function.Function<T,R> f)
Returns the given function object if it is notnull
.static <T> java.util.function.Supplier<T>
ifNull(java.util.function.Supplier<T> s)
Returns the given callback object if it is notnull
.static Callback
ifNull(Callback c)
Returns the given callback object if it is notnull
.static java.lang.Runnable
runnable()
Creates a dummy runnablestatic <T> java.util.function.Supplier<T>
supplier()
Creates a dummy supplier
-
-
-
Method Detail
-
callback
public static Callback callback()
Creates a dummy callback- Returns:
- a dummy callback
-
consumer
public static <T> java.util.function.Consumer<T> consumer()
Creates a dummy consumer- Returns:
- a dummy consumer
-
function
public static <T,R> java.util.function.Function<T,R> function()
Creates a dummy function- Type Parameters:
T
- the input typeR
- the result type- Returns:
- the function
-
supplier
public static <T> java.util.function.Supplier<T> supplier()
Creates a dummy supplier- Type Parameters:
T
- the result type- Returns:
- the supplier
-
runnable
public static java.lang.Runnable runnable()
Creates a dummy runnable- Returns:
- the runnable
-
ifNull
public static <T> java.util.function.Consumer<T> ifNull(java.util.function.Consumer<T> c)
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
public static Callback ifNull(Callback c)
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
public static <T,R> java.util.function.Function<T,R> ifNull(java.util.function.Function<T,R> f)
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
public static <T> java.util.function.Supplier<T> ifNull(java.util.function.Supplier<T> s)
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
public static java.lang.Runnable ifNull(java.lang.Runnable r)
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
-
-