Package org.elasticsearch.common.lease
Enum Releasables
- java.lang.Object
-
- java.lang.Enum<Releasables>
-
- org.elasticsearch.common.lease.Releasables
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Releasables>
public enum Releasables extends java.lang.Enum<Releasables>
Utility methods to work withReleasable
s.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
close(boolean success, java.lang.Iterable<Releasable> releasables)
static void
close(boolean success, Releasable... releasables)
static void
close(java.lang.Iterable<? extends Releasable> releasables)
Release the providedReleasable
s.static void
close(Releasable... releasables)
Release the providedReleasable
s.static void
closeWhileHandlingException(java.lang.Iterable<Releasable> releasables)
Release the providedReleasable
s, ignoring exceptions.static void
closeWhileHandlingException(Releasable... releasables)
Release the providedReleasable
s, ignoring exceptions.static Releasable
releaseOnce(Releasable... releasables)
Equivalent towrap(Releasable...)
but can be called multiple times without double releasing.static Releasables
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static Releasables[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.static Releasable
wrap(java.lang.Iterable<Releasable> releasables)
Wrap several releasables into a single one.static Releasable
wrap(Releasable... releasables)
-
-
-
Method Detail
-
values
public static Releasables[] 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 (Releasables c : Releasables.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Releasables 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
-
close
public static void close(java.lang.Iterable<? extends Releasable> releasables)
Release the providedReleasable
s.
-
close
public static void close(Releasable... releasables)
Release the providedReleasable
s.
-
closeWhileHandlingException
public static void closeWhileHandlingException(java.lang.Iterable<Releasable> releasables)
Release the providedReleasable
s, ignoring exceptions.
-
closeWhileHandlingException
public static void closeWhileHandlingException(Releasable... releasables)
Release the providedReleasable
s, ignoring exceptions.
-
close
public static void close(boolean success, java.lang.Iterable<Releasable> releasables)
-
close
public static void close(boolean success, Releasable... releasables)
-
wrap
public static Releasable wrap(java.lang.Iterable<Releasable> releasables)
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
public static Releasable wrap(Releasable... releasables)
- See Also:
wrap(Iterable)
-
releaseOnce
public static Releasable releaseOnce(Releasable... releasables)
Equivalent towrap(Releasable...)
but can be called multiple times without double releasing.
-
-