-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
StaticVariableSet.java
33 lines (28 loc) · 1.08 KB
/
StaticVariableSet.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package net.aufdemrand.denizen.utilities.javaluator;
import java.util.HashMap;
import java.util.Map;
/** A static variable set.
* <br>Here, static means that the values of variables are set before starting to evaluate the expressions.
* @param <T> The type of the values of the variable (the one handled by the evaluator).
* @author Jean-Marc Astesana
* @see <a href="../../../license.html">License information</a>
*/
public class StaticVariableSet<T> implements AbstractVariableSet<T> {
private final Map<String, T> varToValue;
/** Constructor.
* <br>Builds a new empty variable set.
*/
public StaticVariableSet() {
this.varToValue = new HashMap<String, T>();
}
public T get(String variableName) {
return this.varToValue.get(variableName);
}
/** Sets a variable value.
* @param variableName The variable name
* @param value The variable value (null to remove a variable from the set).
*/
public void set(String variableName, T value) {
this.varToValue.put(variableName, value);
}
}