net.sf.staccatocommons.lang
Class Nulls
java.lang.Object
net.sf.staccatocommons.lang.Nulls
public class Nulls
- extends Object
Class methods to operate with nulls
- Author:
- flbulgarelli
|
Constructor Summary |
Nulls()
|
|
Method Summary |
static
|
coalesce(T value,
T other)
Returns the given value, if non null, or other, otherwise. |
static
|
coalesce(T value,
net.sf.staccatocommons.defs.Thunk<T> thunk)
Returns the given value, if non null, or the value provided by the given
Thunk, otherwise. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Nulls
public Nulls()
coalesce
public static <T> T coalesce(T value,
T other)
- Returns the given value, if non null, or other, otherwise.
- Type Parameters:
T - - Parameters:
value - nullable.other - nullable, although it has little sense to be be null
- Returns:
value != null ? value : other
coalesce
public static <T> T coalesce(T value,
@NonNull
net.sf.staccatocommons.defs.Thunk<T> thunk)
- Returns the given value, if non null, or the value provided by the given
Thunk, otherwise.
- Type Parameters:
T - - Parameters:
value - nullable.thunk - non null.
- Returns:
value != null ? value : thunk.value()
Copyright © 2010-2012 Staccatocommons. All Rights Reserved.