public enum DisposableHelper extends Enum<DisposableHelper> implements Disposable
Enum Constant and Description |
---|
DISPOSED
The singleton instance representing a terminal, disposed state, don't leak it.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Dispose the resource, the operation should be idempotent.
|
static boolean |
dispose(AtomicReference<Disposable> field)
Atomically disposes the Disposable in the field if not already disposed.
|
boolean |
isDisposed()
Returns true if this resource has been disposed.
|
static boolean |
isDisposed(Disposable d)
Checks if the given Disposable is the common
DISPOSED enum value. |
static boolean |
replace(AtomicReference<Disposable> field,
Disposable d)
Atomically replaces the Disposable in the field with the given new Disposable
but does not dispose the old one.
|
static void |
reportDisposableSet()
Reports that the disposable is already set to the RxJavaPlugins error handler.
|
static boolean |
set(AtomicReference<Disposable> field,
Disposable d)
Atomically sets the field and disposes the old contents.
|
static boolean |
setOnce(AtomicReference<Disposable> field,
Disposable d)
Atomically sets the field to the given non-null Disposable and returns true
or returns false if the field is non-null.
|
static boolean |
trySet(AtomicReference<Disposable> field,
Disposable d)
Atomically tries to set the given Disposable on the field if it is null or disposes it if
the field contains
DISPOSED . |
static boolean |
validate(Disposable current,
Disposable next)
Verifies that current is null, next is not null, otherwise signals errors
to the RxJavaPlugins and returns false.
|
static DisposableHelper |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DisposableHelper[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DisposableHelper DISPOSED
public static DisposableHelper[] values()
for (DisposableHelper c : DisposableHelper.values()) System.out.println(c);
public static DisposableHelper valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static boolean isDisposed(Disposable d)
DISPOSED
enum value.d
- the disposable to checkDISPOSED
public static boolean set(AtomicReference<Disposable> field, Disposable d)
field
- the target fieldd
- the new Disposable to setDISPOSED
instance.public static boolean setOnce(AtomicReference<Disposable> field, Disposable d)
field
- the target fieldd
- the disposable to set, not nullpublic static boolean replace(AtomicReference<Disposable> field, Disposable d)
field
- the target field to changed
- the new disposable, null allowedpublic static boolean dispose(AtomicReference<Disposable> field)
field
- the target fieldpublic static boolean validate(Disposable current, Disposable next)
current
- the current Disposable, expected to be nullnext
- the next Disposable, expected to be non-nullpublic static void reportDisposableSet()
public static boolean trySet(AtomicReference<Disposable> field, Disposable d)
DISPOSED
.field
- the target fieldd
- the disposable to setpublic void dispose()
Disposable
dispose
in interface Disposable
public boolean isDisposed()
Disposable
isDisposed
in interface Disposable
Copyright © 2019. All rights reserved.