Package rx.internal.util
Enum ExceptionsUtils
- java.lang.Object
-
- java.lang.Enum<ExceptionsUtils>
-
- rx.internal.util.ExceptionsUtils
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ExceptionsUtils>
public enum ExceptionsUtils extends java.lang.Enum<ExceptionsUtils>
Utility methods for terminal atomics with Throwables.- Since:
- 1.1.2
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Throwable
TERMINATED
The single instance of a Throwable indicating a terminal state.
-
Constructor Summary
Constructors Modifier Constructor Description private
ExceptionsUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
addThrowable(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field, java.lang.Throwable error)
Atomically sets or combines the error with the contents of the field, wrapping multiple errors into CompositeException if necessary.static boolean
isTerminated(java.lang.Throwable error)
Returns true if the value is the terminated Throwable instance.static boolean
isTerminated(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field)
Checks if the given field holds the terminated Throwable instance.static java.lang.Throwable
terminate(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field)
Atomically swaps in the terminal Throwable and returns the previous contents of the fieldstatic ExceptionsUtils
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static ExceptionsUtils[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static ExceptionsUtils[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ExceptionsUtils c : ExceptionsUtils.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ExceptionsUtils valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
addThrowable
public static boolean addThrowable(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field, java.lang.Throwable error)
Atomically sets or combines the error with the contents of the field, wrapping multiple errors into CompositeException if necessary.- Parameters:
field
- the target fielderror
- the error to add- Returns:
- true if successful, false if the target field contains the terminal Throwable.
-
terminate
public static java.lang.Throwable terminate(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field)
Atomically swaps in the terminal Throwable and returns the previous contents of the field- Parameters:
field
- the target field- Returns:
- the previous contents of the field before the swap, may be null
-
isTerminated
public static boolean isTerminated(java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> field)
Checks if the given field holds the terminated Throwable instance.- Parameters:
field
- the target field- Returns:
- true if the given field holds the terminated Throwable instance
-
isTerminated
public static boolean isTerminated(java.lang.Throwable error)
Returns true if the value is the terminated Throwable instance.- Parameters:
error
- the error to check- Returns:
- true if the value is the terminated Throwable instance
-
-