public class ReferenceWithError<T>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
checkNoError()
throws if there is an error (even if masked)
|
T |
get()
returns the underlying value, throwing if there is an error which is not masked (ie
#throwsErrorOnAccess() is set) |
java.lang.Throwable |
getError()
returns the error (not throwing)
|
T |
getWithError()
throws error, even if there is one (even if masked), else returns the object
|
T |
getWithoutError()
returns the object, ignoring any error (even non-masked)
|
boolean |
hasError()
true if there is an error (whether masked or not)
|
boolean |
masksErrorIfPresent()
whether this will mask any error on an attempt to
get() ;
if false (if created with newInstanceThrowingError(Object, Throwable) ) a call to get() will throw if there is an error;
true if created with newInstanceMaskingError(Object, Throwable) and get() will not throw |
static <T> ReferenceWithError<T> |
newInstanceMaskingError(T object,
java.lang.Throwable error)
returns a reference which includes an error, but attempts to get the content do not cause the error to throw
|
static <T> ReferenceWithError<T> |
newInstanceThrowingError(T object,
java.lang.Throwable error)
returns a reference which includes an error, and where attempts to get the content cause the error to throw
|
static <T> ReferenceWithError<T> |
newInstanceWithoutError(T object)
returns a reference which includes an error, but attempts to get the content do not cause the error to throw
|
java.lang.String |
toString() |
public static <T> ReferenceWithError<T> newInstanceThrowingError(T object, java.lang.Throwable error)
public static <T> ReferenceWithError<T> newInstanceMaskingError(T object, java.lang.Throwable error)
public static <T> ReferenceWithError<T> newInstanceWithoutError(T object)
public boolean masksErrorIfPresent()
get()
;
if false (if created with newInstanceThrowingError(Object, Throwable)
) a call to get()
will throw if there is an error;
true if created with newInstanceMaskingError(Object, Throwable)
and get()
will not throwpublic T get()
#throwsErrorOnAccess()
is set)public T getWithoutError()
public T getWithError()
public void checkNoError()
public java.lang.Throwable getError()
public boolean hasError()
public java.lang.String toString()
toString
in class java.lang.Object