public interface Initializable
Class.newInstance()
.
This interface presents different ways to pass the initialization parameters to the instance object to initialize.
The philosophy of this design is that the user should implement at least 1 method of initialization and set the "can" methods accordingly. The user should use the "can" methods to determine which initialization methods are available. The user is not required to implement all input methods.
Modifier and Type | Method and Description |
---|---|
boolean |
canInitFromArray()
Checks if this object can initialize with the method
initFromArray(java.lang.Object[]) . |
boolean |
canInitFromMap()
Checks if this object can initialize with the method
initFromMap(java.util.Map) . |
boolean |
canInitFromString()
Checks if this object can initialize with the method
initFromString(java.lang.String) . |
void |
initFromArray(Object[] params)
Initializes the instance with an array of parameters.
|
void |
initFromMap(Map<String,Object> params)
Initializes the instance with parameters given in a Map collection.
|
void |
initFromString(String params)
Initializes the instance with all parameters given in a single string.
|
void initFromArray(Object[] params)
params
- the parametersvoid initFromString(String params)
String.split(java.lang.String)
.
The full details of the implementation are left to the user.
Another implementation idea is that params
defines the filename that
contains the object parameters. This instance would then have to read from this file.
If the user wants to pass an array of strings, then he should use initFromArray(java.lang.Object[])
.
params
- the parameters concatenated into a single stringvoid initFromMap(Map<String,Object> params)
String
and the parameter
value is an Object
.params
- the map collection that contains the parameters, where the key
is the name and the value is the parameterboolean canInitFromArray()
initFromArray(java.lang.Object[])
.true
if yes, otherwise false
boolean canInitFromString()
initFromString(java.lang.String)
.true
if yes, otherwise false
boolean canInitFromMap()
initFromMap(java.util.Map)
.true
if yes, otherwise false