Package com.rabbitmq.utility
Class ValueOrException<V,E extends Throwable & SensibleClone<E>>
java.lang.Object
com.rabbitmq.utility.ValueOrException<V,E>
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ValueOrException
(V value, E exception, boolean useValue) dual-purpose private constructor: one will be null, and the flag tells which to use -
Method Summary
Modifier and TypeMethodDescriptiongetValue()
Retrieve value or throw exceptionstatic <V,
E extends Throwable & SensibleClone<E>>
ValueOrException<V, E> makeException
(E exception) Factory method for exceptionsstatic <V,
E extends Throwable & SensibleClone<E>>
ValueOrException<V, E> makeValue
(V value) Factory method for values
-
Field Details
-
_useValue
private final boolean _useValue -
_value
-
_exception
-
-
Constructor Details
-
ValueOrException
dual-purpose private constructor: one will be null, and the flag tells which to use- Parameters:
value
- the value to wrap, if applicableexception
- the exception to wrap, if applicableuseValue
- true if we should use the value, rather than the exception
-
-
Method Details
-
makeValue
Factory method for values- Parameters:
value
- the value to wrap as a ValueOrException- Returns:
- the wrapped value
-
makeException
public static <V,E extends Throwable & SensibleClone<E>> ValueOrException<V,E> makeException(E exception) Factory method for exceptions- Parameters:
exception
- the exception to wrap as a ValueOrException- Returns:
- the wrapped exception
-
getValue
Retrieve value or throw exception- Returns:
- the wrapped value, if it's a value
- Throws:
E
- the wrapped exception, if it's an exception
-