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>,java.lang.constant.Constable
public enum Releasables extends java.lang.Enum<Releasables>
Utility methods to work with
Releasables.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
java.lang.Enum.EnumDesc<E extends java.lang.Enum<E>> -
Method Summary
Modifier and Type Method Description static voidclose(boolean success, java.lang.Iterable<Releasable> releasables)static voidclose(boolean success, Releasable... releasables)static voidclose(java.lang.Iterable<? extends Releasable> releasables)Release the providedReleasables.static voidclose(Releasable releasable)Release the providedReleasable.static voidclose(Releasable... releasables)Release the providedReleasables.static voidcloseExpectNoException(Releasable releasable)Release the providedReleasableexpecting no exception to by thrown.static voidcloseExpectNoException(Releasable... releasables)Release the providedReleasables expecting no exception to by thrown by any of them.static voidcloseWhileHandlingException(Releasable... releasables)Release the providedReleasables, ignoring exceptions.static ReleasablereleaseOnce(Releasable releasable)Wraps aReleasablesuch that itsReleasable.close()method can be called multiple times without double releasing.static ReleasablesvalueOf(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 Releasablewrap(java.lang.Iterable<Releasable> releasables)Wrap several releasables into a single one.static Releasablewrap(Releasable... releasables)Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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
Release the providedReleasables. -
close
Release the providedReleasable. -
close
Release the providedReleasables. -
closeExpectNoException
Release the providedReleasables expecting no exception to by thrown by any of them. -
closeExpectNoException
Release the providedReleasableexpecting no exception to by thrown. -
closeWhileHandlingException
Release the providedReleasables, 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:
wrap(Iterable)
-
releaseOnce
Wraps aReleasablesuch that itsReleasable.close()method can be called multiple times without double releasing.
-