Enum Class Releasables

java.lang.Object
java.lang.Enum<Releasables>
org.elasticsearch.core.Releasables
All Implemented Interfaces:
Serializable, Comparable<Releasables>, Constable

public enum Releasables extends Enum<Releasables>
Utility methods to work with Releasables.
  • Method Details

    • values

      public static Releasables[] 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

      public static Releasables valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • close

      public static void close(Iterable<? extends Releasable> releasables)
      Release the provided Releasables.
    • close

      public static void close(@Nullable Releasable releasable)
      Release the provided Releasable.
    • close

      public static void close(Releasable... releasables)
      Release the provided Releasables.
    • closeExpectNoException

      public static void closeExpectNoException(Releasable... releasables)
      Release the provided Releasables expecting no exception to by thrown by any of them.
    • closeExpectNoException

      public static void closeExpectNoException(Releasable releasable)
      Release the provided Releasable expecting no exception to by thrown.
    • closeWhileHandlingException

      public static void closeWhileHandlingException(Releasable... releasables)
      Release the provided Releasables, ignoring exceptions.
    • close

      public static void close(boolean success, Iterable<Releasable> releasables)
      Release the provided Releasables, ignoring exceptions if success is false.
    • close

      public static void close(boolean success, Releasable... releasables)
      Release the provided Releasables, ignoring exceptions if success is false.
    • wrap

      public static Releasable wrap(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:
    • releaseOnce

      public static Releasable releaseOnce(Releasable releasable)
      Wraps a Releasable such that its Releasable.close() method can be called multiple times without double releasing.