public class VariableRepository
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static VariableRepository |
instance
The unique instance of the class prepared in an eager way (object created
at beginning).
|
private java.util.HashMap<java.lang.String,java.lang.Integer> |
values
This
HashMap contains all registered variable values. |
Modifier | Constructor and Description |
---|---|
private |
VariableRepository()
Private constructor ensuring no access from outside of the class.
|
Modifier and Type | Method and Description |
---|---|
static VariableRepository |
getInstance()
Static method allows users to get the unique instance of the class.
|
int |
getValue(java.lang.String name)
Gets the value for a registered variable.
|
void |
register(java.lang.String name,
int value)
To register the value for a variable, we specify the variable name and
the expected current value for the variable.
|
private java.util.HashMap<java.lang.String,java.lang.Integer> values
HashMap
contains all registered variable values. The key is
variable name (unique) and the value is the current variable's value.private static VariableRepository instance
private VariableRepository()
public static VariableRepository getInstance()
public void register(java.lang.String name, int value)
name
- the name of the variable for which we wish to register the
(new) valuevalue
- the value for the variablepublic int getValue(java.lang.String name)
name
- the name of the variable