Package org.opensearch.common.lease
Enum Class Releasables
- All Implemented Interfaces:
Serializable
,Comparable<Releasables>
,Constable
Utility methods to work with
Releasable
s.- Opensearch.internal:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
close
(boolean success, Iterable<Releasable> releasables) static void
close
(boolean success, Releasable... releasables) static void
close
(Iterable<? extends Releasable> releasables) Release the providedReleasable
s.static void
close
(Releasable releasable) Release the providedReleasable
.static void
close
(Releasable... releasables) Release the providedReleasable
s.static void
closeWhileHandlingException
(Iterable<? extends Releasable> releasables) Release the providedReleasable
s, ignoring exceptions.static void
closeWhileHandlingException
(Releasable... releasables) Release the providedReleasable
s, ignoring exceptions.static Releasable
releaseOnce
(Releasable releasable) Wraps aReleasable
such that itsReleasable.close()
method can be called multiple times without double releasing.static Releasables
Returns the enum constant of this class with the specified name.static Releasables[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.static Releasable
wrap
(Iterable<Releasable> releasables) Wrap several releasables into a single one.static Releasable
wrap
(Releasable... releasables)
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
close
Release the providedReleasable
s. -
close
Release the providedReleasable
. -
close
Release the providedReleasable
s. -
closeWhileHandlingException
Release the providedReleasable
s, ignoring exceptions. -
closeWhileHandlingException
Release the providedReleasable
s, ignoring exceptions. -
close
-
close
-
wrap
Wrap several releasables into a single one. This is typically useful for use with try-with-resources: for example let's assume that you store in a list several resources that you would like to see released after execution of the try block:List<Releasable> resources = ...; try (Releasable releasable = Releasables.wrap(resources)) { // do something } // the resources will be released when reaching here
-
wrap
- See Also:
-
releaseOnce
Wraps aReleasable
such that itsReleasable.close()
method can be called multiple times without double releasing.
-