Interface Blockable

All Known Implementing Classes:
Block

public interface Blockable
Interface that allows objects to be blocked. Blocking an object is typically a means of preventing the object from doing something. For example, if a dispenser process should no be run with the door open (such as agitating ingredients), the process can be made Blockable and opening the door can apply a block. Closing the door can then remove the block to allow the process to continue.

Blocks are applied using a reason object. The reason can be any object so long as the same object is used to remove the block. Typically the object is selected such that when debugging, the reason indicates the source of the block.

A Blockable object is considered blocked so long as any block exists. This allows for easy integration of blocking logic without requiring any extenal coordination.

A Blockable object is typically backed by a Block object which handles all the block tracking logic and provides callbacks when the first block is applied and the last block is removed.

Since:
1.0
Version:
2023-02-27
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    block(Object reason)
    Block the object for the specified reason.
    boolean
    Return true is the object is blocked.
    void
    unblock(Object reason)
    Remove a block with the specified reason.
  • Method Details

    • isBlocked

      boolean isBlocked()
      Return true is the object is blocked.
    • block

      void block(Object reason)
      Block the object for the specified reason. The same reason must be used to unblock.
      Parameters:
      reason - the reason to block
    • unblock

      void unblock(Object reason)
      Remove a block with the specified reason.
      Parameters:
      reason - the reason used to block