@Evolving public class Utils extends Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
closeCloseables(AutoCloseable... closeables)
Close the given one or more
AutoCloseables. |
static void |
closeCloseablesSilently(AutoCloseable... closeables)
Close the given list of
AutoCloseable objects. |
static <T> CloseableIterator<T> |
singletonCloseableIterator(T elem)
Utility method to create a singleton
CloseableIterator. |
static <T> CloseableIterator<T> |
toCloseableIterator(java.util.Iterator<T> iter)
Convert a
Iterator to CloseableIterator. |
public static <T> CloseableIterator<T> singletonCloseableIterator(T elem)
CloseableIterator.T - Element type.elem - Element to create iterator with.CloseableIterator with just one element.public static <T> CloseableIterator<T> toCloseableIterator(java.util.Iterator<T> iter)
Iterator to CloseableIterator. Useful when passing normal iterators
for arguments that require CloseableIterator type.T - Element typeiter - Iterator instanceCloseableIterator wrapping the given Iteratorpublic static void closeCloseables(AutoCloseable... closeables)
AutoCloseables. AutoCloseable.close()
will be called on all given non-null closeables. Will throw unchecked
RuntimeException if an error occurs while closing. If multiple closeables causes
exceptions in closing, the exceptions will be added as suppressed to the main exception
that is thrown.closeables - public static void closeCloseablesSilently(AutoCloseable... closeables)
AutoCloseable objects. Any exception thrown is
silently ignored.closeables -