-
Notifications
You must be signed in to change notification settings - Fork 0
/
DisEnum.java
46 lines (38 loc) · 944 Bytes
/
DisEnum.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
34
35
36
37
38
39
40
41
42
43
44
45
46
package dev.alephpt.Dis;
import java.util.List;
import java.util.Map;
class DisEnum implements DisCaller{
final String name;
private final Map<String, Integer> elements; // need to turn this into an array
DisEnum(String name, Map<String, Integer> elements) {
this.name = name;
this.elements = elements;
}
Integer findElement(String name) {
if (elements.containsKey(name)) {
return elements.get(name);
}
return null;
}
String findElementName(Integer el) {
for(Map.Entry<String, Integer> element : elements.entrySet()) {
if(element.getValue() == el) {
return element.getKey();
}
}
return null;
}
@Override
public Object call(Interpreter interpreter, List<Object> arguments) {
DisSample sample = new DisSample(this);
return sample;
}
@Override
public int arity() {
return 0;
}
@Override
public String toString() {
return name;
}
}