public final class AutoCloseables extends Object
| 修飾子とタイプ | クラスと説明 |
|---|---|
static class |
AutoCloseables.RollbackCloseable
A closeable wrapper that will close the underlying closeables if a commit does not occur.
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
static AutoCloseable |
all(Collection<? extends AutoCloseable> autoCloseables) |
static void |
close(AutoCloseable... autoCloseables)
Closes all autoCloseables if not null and suppresses subsequent exceptions if more than one.
|
static void |
close(Iterable<? extends AutoCloseable>... closeables) |
static void |
close(Iterable<? extends AutoCloseable> ac)
Closes all autoCloseables if not null and suppresses subsequent exceptions if more than one.
|
static void |
close(Throwable t,
AutoCloseable... autoCloseables)
Closes all autoCloseables if not null and suppresses exceptions by adding them to t.
|
static void |
close(Throwable t,
Iterable<? extends AutoCloseable> autoCloseables)
Closes all autoCloseables if not null and suppresses exceptions by adding them to t.
|
static void |
closeNoChecked(AutoCloseable autoCloseable)
close() an
AutoCloseable without throwing a (checked)
Exception. |
static Iterable<AutoCloseable> |
iter(AutoCloseable... ac) |
static AutoCloseable |
noop() |
static AutoCloseables.RollbackCloseable |
rollbackable(AutoCloseable... closeables) |
public static AutoCloseable all(Collection<? extends AutoCloseable> autoCloseables)
public static void close(Throwable t, AutoCloseable... autoCloseables)
t - the throwable to add suppressed exception toautoCloseables - the closeables to closepublic static void close(Throwable t, Iterable<? extends AutoCloseable> autoCloseables)
t - the throwable to add suppressed exception toautoCloseables - the closeables to closepublic static void close(AutoCloseable... autoCloseables) throws Exception
autoCloseables - the closeables to closeExceptionpublic static void close(Iterable<? extends AutoCloseable> ac) throws Exception
ac - the closeables to closeException@SafeVarargs public static void close(Iterable<? extends AutoCloseable>... closeables) throws Exception
Exceptionpublic static Iterable<AutoCloseable> iter(AutoCloseable... ac)
public static AutoCloseables.RollbackCloseable rollbackable(AutoCloseable... closeables)
public static void closeNoChecked(AutoCloseable autoCloseable)
AutoCloseable without throwing a (checked)
Exception. This wraps the close() call with a
try-catch that will rethrow an Exception wrapped with a
RuntimeException, providing a way to call close()
without having to do the try-catch everywhere or propagate the Exception.autoCloseable - the AutoCloseable to close; may be nullRuntimeException - if an Exception occurs; the Exception is
wrapped by the RuntimeExceptionpublic static AutoCloseable noop()
Copyright © 2018 The Apache Software Foundation. All rights reserved.