Class AbstractLockable<T extends AbstractLockable<T>>

java.lang.Object
net.sf.basedb.opengrid.config.AbstractLockable<T>
Direct Known Subclasses:
BatchConfig, ClusterConfig, ConnectionInfo, JobConfig, JSONOptions, NodeConfig

public abstract class AbstractLockable<T extends AbstractLockable<T>>
extends Object
Handles locking and validation of configuration settings. The generic parameter must be the subclass iteself so the the lock() method can return the "this" reference.
Since:
1.0
Author:
nicklas
  • Field Details

    • locked

      private boolean locked
    • valid

      private boolean valid
  • Constructor Details

    • AbstractLockable

      protected AbstractLockable()
  • Method Details

    • isValid

      public final boolean isValid()
      Check if this configuration is valid or not.
    • checkValid

      protected void checkValid​(boolean forLock)
      Check if the configuration settings are valid. The default implementation does nothing. Subclasses should override this method to implement their own validation and throw an exception if the configuration is not valid.
      Parameters:
      forLock - If TRUE, the instance will be locked after validation
    • isLocked

      public final boolean isLocked()
      Is this instance locked for modifications?
    • lock

      public final T lock()
      Lock this instance for future modifications. The lock will only succeed if the configuration is valid.
      Returns:
      This instance
    • checkLocked

      protected final void checkLocked​(String method)
      Check the locked status and throw an IllegalStateException if this instance has been locked. Calling this method resets the validation status of this configuration.
      Parameters:
      method - The name of the method that is trying to modify this instance