Package de.aristaflow.adept2.util.io
Class IoTools.Unchecked<C extends AutoCloseable>
java.lang.Object
de.aristaflow.adept2.util.io.IoTools.Unchecked<C>
- Type Parameters:
C- The type of the closeable of which to wrap any exception fromAutoCloseable.close().
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- IoTools
This class wraps an
AutoCloseable and wraps the exception from
closing in a RuntimeException if necessary.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new unconditional closeable wrapping the designatedAutoCloseablewrapping any exception fromAutoCloseable.close().protectedCreates a new conditional closeable wrapping the designatedAutoCloseablewrapping any exception fromAutoCloseable.close(). -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected booleanevalCond()Gets whether to close or not.Gets the wrappedAutoCloseable.
-
Field Details
-
condition
The optional condition allowing for conditional closing. If this isnull, unconditional closing will apply. -
wrapped
The wrappedAutoCloseable.
-
-
Constructor Details
-
Unchecked
Creates a new unconditional closeable wrapping the designatedAutoCloseablewrapping any exception fromAutoCloseable.close().- Parameters:
wrapped- The wrappedAutoCloseable.
-
Unchecked
Creates a new conditional closeable wrapping the designatedAutoCloseablewrapping any exception fromAutoCloseable.close().- Parameters:
condition- The optional condition allowing for conditional closing ornullfor unconditional closing.wrapped- The wrappedAutoCloseable.
-
-
Method Details
-
close
public void close() -
evalCond
protected boolean evalCond()Gets whether to close or not.- Returns:
- Whether to close or not.
-
getWrapped
Gets the wrappedAutoCloseable.- Returns:
- The wrapped
AutoCloseable.
-