public final class NotNullizer
extends java.lang.Object
null-object instance, which is hidden from outside world, preventing accidental "unwrapping".| Constructor and Description |
|---|
NotNullizer(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
notNullize(T value)
"Wraps"
null with null-object. |
<T> T |
nullize(T value)
"Unwraps"
null from the value returned by notNullize(Object). |
public <T> T notNullize(T value)
null with null-object.
Useful when some generic data structure A does not allow nulls,
but there is a need to implement another structure B on top of A which should support nulls.
nullize(Object).
Object will result in ClassCastException,
this means the value cannot be used anywhere where T is a specific type different from Object.null wrapper if value is null, otherwise original valuenullize(Object)public <T> T nullize(T value)
null from the value returned by notNullize(Object).null if value is the null wrapper, otherwise original valuenotNullize(Object)