|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.lucidviews.util.NotNull<T>
T
- the type of variable being wrappedpublic class NotNull<T>
A wrapper class for maintaining a variable in a not-null state.
The wrapper class will perform checks to ensure the variable is never set to null.
Performing the null pointer check when a value is set removes the need to check for
a null pointer when the value is used/accessed.
It also ensures that any process fails early (at the time when an inappropriate value is computed/assigned)
rather than allowing the program to continue until the value is accessed.
Field Summary | |
---|---|
protected T |
value
The current value. |
Constructor Summary | |
---|---|
NotNull(T value)
Create a variable that is always guaranteed not null. |
Method Summary | ||
---|---|---|
T |
getValue()
Get the value. |
|
static
|
instance(T value)
Create a NotNull variable using an initial value. |
|
void |
setValue(T value)
Change the value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected T value
Constructor Detail |
---|
public NotNull(T value)
null
an IllegalNullValueException
will be thrown.
value
- the initial value, which can't be nullMethod Detail |
---|
public static <T> NotNull<T> instance(T value)
NotNull
variable using an initial value.
NotNull
class.
T
- the type of variable being wrappedvalue
- the initial value, which can't be null
NotNull
wrapper around the original value
public void setValue(T value)
null
an IllegalNullValueException
will be thrown.
value
- the new value, which can't be nullpublic T getValue()
null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |