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) or null if no error
|
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,U extends T> |
newInstanceMaskingError(U 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
(unless the error supplied is null in which case behaviour is as per
newInstanceWithoutError(Object) ) |
static <T,U extends T> |
newInstanceThrowingError(U object,
java.lang.Throwable error)
returns a reference which includes an error, and where attempts to get the content cause the error to throw
(unless the error supplied is null in which case behaviour is as per
newInstanceWithoutError(Object) ) |
static <T,U extends T> |
newInstanceWithoutError(U object)
returns a reference which does not have any error; attempts to get the content are safe
|
java.lang.String |
toString() |
public static <T,U extends T> ReferenceWithError<T> newInstanceThrowingError(@Nullable U object, @Nullable java.lang.Throwable error)
newInstanceWithoutError(Object)
)public static <T,U extends T> ReferenceWithError<T> newInstanceMaskingError(@Nullable U object, @Nullable java.lang.Throwable error)
newInstanceWithoutError(Object)
)public static <T,U extends T> ReferenceWithError<T> newInstanceWithoutError(@Nullable U 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