public interface Configurable
Configurable
interface is meant to be used as an interface / paradigm for any class that separates
construction-time configuration methods from the rest of the instance's lifecycle. It is particularly appropriate for
classes that need a large number of parameters and consider both optional and default parameters.
While the interface itself does not offer many methods, it is expected from a class implementing Configurable
that it will offer a number of setters, and will respect the guidelines set in Config
.
For further reference on this paradigm, see Config
.
Modifier and Type | Method and Description |
---|---|
Config |
build()
This method should always be an alias of
lock() . |
void |
ensureLocked()
This method should check the locking status and call
lock() only once in the lifetime of the
instance. |
Config |
lock()
'Locks' the configuration, meaning that construction time is over.
|
void |
locked()
Should be called at the entry point of methods that should not be called after the instance has been 'locked'.
|
Configurable |
makeDefaults()
Initializes all optional parameters to their default value.
|
Configurable makeDefaults()
From Config
guidelines:
Config lock()
in case any construction needs to be made, it should be done in this method, after calling
super.lock()
.
Config build()
lock()
. The difference is only semantic:
build()
should be associated with actually building the configured instance, and lock()
should be associated with locking the configuration / values of configured parameters.void ensureLocked()
lock()
only once in the lifetime of the
instance.
This can be called by various methods that need to ensure the locking has been performed, also resulting in a
call to lock()
the first time this method is called.
void locked() throws Config.ConfigLockedException
In case such a call is made, the method should throw the specified exception.
Config.ConfigLockedException