Package com.dtolabs.rundeck.core.plugins
Class Closeables
- java.lang.Object
-
- com.dtolabs.rundeck.core.plugins.Closeables
-
public class Closeables extends java.lang.Object- Since:
- 3/8/17
-
-
Field Summary
Fields Modifier and Type Field Description static java.io.CloseableNO_OPA closeable which does nothing
-
Constructor Summary
Constructors Constructor Description Closeables()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> CloseableProvider<T>closeableProvider(T object)static <T> CloseableProvider<T>closeableProvider(T object, java.io.Closeable closer)static voidcloseAll(boolean throwIOException, boolean throwLast, java.io.Closeable... closeables)static voidcloseAll(java.io.Closeable... closeables)Close all closeables and throw any final exceptionstatic voidcloseAll(java.util.Collection<java.io.Closeable> closeables)static java.io.CloseablecloseOnce(java.io.Closeable closer)static voidcloseQuietly(java.io.Closeable... closeables)Close all closeables quietlystatic voidcloseQuietly(java.util.Collection<java.io.Closeable> closeables)static java.io.CloseablemaybeCloseable(java.lang.Object object)If the input object is a Closeable, return it, otherwise return a non-null Closeable which does nothing.static java.io.Closeablesingle(boolean throwIOException, boolean throwLast, java.io.Closeable... closeables)Create a single Closeable which closes all of the specified closeablesstatic java.io.Closeablesingle(boolean throwIOException, java.io.Closeable... closeables)Create a single Closeable which closes all of the specified closeablesstatic java.io.Closeablesingle(boolean throwIOException, java.util.Collection<java.io.Closeable> closeables)Create a single Closeable which closes all of the specified closeablesstatic java.io.Closeablesingle(java.io.Closeable... closeables)Create a single Closeable which closes all of the specified closeables and throws IOExceptionsstatic java.io.Closeablesingle(java.util.Collection<java.io.Closeable> closeables)Create a single Closeable which closes all of the specified closeables and throws IOExceptions
-
-
-
Method Detail
-
closeableProvider
public static <T> CloseableProvider<T> closeableProvider(T object)
-
closeOnce
public static java.io.Closeable closeOnce(java.io.Closeable closer)
-
closeableProvider
public static <T> CloseableProvider<T> closeableProvider(T object, java.io.Closeable closer)
-
maybeCloseable
public static java.io.Closeable maybeCloseable(java.lang.Object object)
If the input object is a Closeable, return it, otherwise return a non-null Closeable which does nothing.- Parameters:
object- object which might be closeable- Returns:
- a closeable
-
single
public static java.io.Closeable single(boolean throwIOException, java.util.Collection<java.io.Closeable> closeables)Create a single Closeable which closes all of the specified closeables- Parameters:
throwIOException- if true, throw any IOException encounteredcloseables- collection of closeables- Returns:
- closeable
-
single
public static java.io.Closeable single(java.util.Collection<java.io.Closeable> closeables)
Create a single Closeable which closes all of the specified closeables and throws IOExceptions- Parameters:
closeables- closeables- Returns:
- closeable which silently closes all in the collection
-
single
public static java.io.Closeable single(java.io.Closeable... closeables)
Create a single Closeable which closes all of the specified closeables and throws IOExceptions- Parameters:
closeables- closeables- Returns:
- closeable which silently closes all in the array
-
single
public static java.io.Closeable single(boolean throwIOException, java.io.Closeable... closeables)Create a single Closeable which closes all of the specified closeables- Parameters:
throwIOException- if true, throw the final IOException encounteredcloseables- array of closeables- Returns:
- closeable
-
single
public static java.io.Closeable single(boolean throwIOException, boolean throwLast, java.io.Closeable... closeables)Create a single Closeable which closes all of the specified closeables- Parameters:
throwIOException- if true, throw an IOException if encountered, otherwise do not throw anythingthrowLast- if true, only throw the last IOException encountered, otherwise throw the firstcloseables- array of closeables- Returns:
- closeable
-
closeQuietly
public static void closeQuietly(java.util.Collection<java.io.Closeable> closeables)
-
closeAll
public static void closeAll(java.util.Collection<java.io.Closeable> closeables) throws java.io.IOException- Throws:
java.io.IOException
-
closeAll
public static void closeAll(java.io.Closeable... closeables) throws java.io.IOExceptionClose all closeables and throw any final exception- Parameters:
closeables-- Throws:
java.io.IOException
-
closeQuietly
public static void closeQuietly(java.io.Closeable... closeables)
Close all closeables quietly- Parameters:
closeables-
-
closeAll
public static void closeAll(boolean throwIOException, boolean throwLast, java.io.Closeable... closeables) throws java.io.IOException- Throws:
java.io.IOException
-
-