Package org.refcodes.component
Interface ClosableHandle<H>
-
- Type Parameters:
H
- The type of the handle.
- All Known Subinterfaces:
ClosableHandle.CloseAutomatonHandle<H>
,ConnectionComponentHandle<H,CON>
,ConnectionComponentHandle.ConnectionAutomatonHandle<H,CON>
,LinkComponentHandle<H>
,LinkComponentHandle.DeviceAutomatonHandle<H>
public interface ClosableHandle<H>
TheClosableHandle
interface defines those methods related to the handle based close life-cycle.The handle reference requires the
Closable
interface to be implemented.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ClosableHandle.CloseAutomatonHandle<H>
TheClosableHandle.CloseAutomatonHandle
interface defines those methods related to the handle based close life-cycle.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close(H aHandle)
Closes or pre-closes (flush) the component identified by the given handle.default void
closeUnchecked(H aHandle)
Closes the component by callingclose(Object)
without you to require catching anCloseException
.boolean
hasClosable(H aHandle)
Determines whether the handle reference is closable by implementing theClosable
interface.
-
-
-
Method Detail
-
hasClosable
boolean hasClosable(H aHandle) throws UnknownHandleRuntimeException
Determines whether the handle reference is closable by implementing theClosable
interface.- Parameters:
aHandle
- The handle to test whether the reference provides the according functionality.- Returns:
- True in case the reference provides the according functionality.
- Throws:
UnknownHandleRuntimeException
- in case the handle is unknown.
-
close
void close(H aHandle) throws CloseException, UnknownHandleRuntimeException, UnsupportedHandleOperationRuntimeException, IllegalHandleStateChangeRuntimeException
Closes or pre-closes (flush) the component identified by the given handle. Throws aCloseException
as upon close we may have to do things like flushing buffers which can fail (and would otherwise fail unhandled or even worse unnoticed).- Parameters:
aHandle
- The handle identifying the component.- Throws:
CloseException
- Thrown in case closing or pre-closing (flushing) fails.UnknownHandleRuntimeException
- in case the given handle is unknown.UnsupportedHandleOperationRuntimeException
- in case the reference of the handle does not support the requested operation.IllegalHandleStateChangeRuntimeException
- Thrown in case a state change is not possible due to the current state the referenced component is in.
-
closeUnchecked
default void closeUnchecked(H aHandle)
Closes the component by callingclose(Object)
without you to require catching anCloseException
.- Parameters:
aHandle
- The handle identifying the component.- Throws:
org.refcodes.exception.HiddenException
- encapsulates the cause and is thrown upon encountering aCloseException
exception
-
-