Package com.tccc.kos.commons.util
Class Block
java.lang.Object
com.tccc.kos.commons.util.Block
- All Implemented Interfaces:
Blockable
Implementation of the
Blockable
interface. This is typically used
by objects that implement Blockable
to perform the actual block
behavior.
This provides callbacks for onBlocked
and onUnblocked
which
are called when the first block is added or the last block is removed.
- Since:
- 1.0
- Version:
- 2023-02-27
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Block the object for the specified reason.void
blocked()
Called when transitioning to a blocked state.boolean
Return true is the object is blocked.setOnBlocked
(Runnable callback) Set the callback to run when transitioning to a blocked state.setOnUnblocked
(Runnable callback) Set the callback to run when transitioning to an unblocked state.void
Remove a block with the specified reason.void
Called when transitioning to an unblocked state.
-
Constructor Details
-
Block
public Block()
-
-
Method Details
-
setOnBlocked
Set the callback to run when transitioning to a blocked state.- Parameters:
callback
- the callback to call
-
setOnUnblocked
Set the callback to run when transitioning to an unblocked state.- Parameters:
callback
- the callback to call
-
blocked
public void blocked()Called when transitioning to a blocked state. Override as needed or usesetOnBlocked()
. -
unblocked
public void unblocked()Called when transitioning to an unblocked state. Override as needed or usesetOnUnblocked()
. -
isBlocked
public boolean isBlocked()Description copied from interface:Blockable
Return true is the object is blocked. -
block
Description copied from interface:Blockable
Block the object for the specified reason. The same reason must be used to unblock. -
unblock
Description copied from interface:Blockable
Remove a block with the specified reason. -
getOnBlocked
-
getOnUnblocked
-