Package net.sf.basedb.opengrid.config
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
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
checkLocked
(String method) Check the locked status and throw anIllegalStateException
if this instance has been locked.protected void
checkValid
(boolean forLock) Check if the configuration settings are valid.final boolean
isLocked()
Is this instance locked for modifications?final boolean
isValid()
Check if this configuration is valid or not.final T
lock()
Lock this instance for future modifications.
-
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
Lock this instance for future modifications. The lock will only succeed if the configuration is valid.- Returns:
- This instance
-
checkLocked
Check the locked status and throw anIllegalStateException
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
-