-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnums.js
54 lines (50 loc) · 1.1 KB
/
Enums.js
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
47
48
49
50
51
52
53
54
class EnumInstance {
template = null;
property = null;
constructor(template) {
this.template = template;
this.property = null;
}
set(property) {
this.property = property;
}
compare(property) {
return this.property === property;
}
}
class EnumTemplate {
properties = [];
instance = null;
addProperty(property) {
property.instance = this.instance;
this.properties.push(property);
}
getProperty(identifier) {
for(const property of this.properties) {
if(property.identifier === identifier) {
return property;
}
}
return null;
}
constructor() {
this.properties = [];
}
createInstance() {
return new EnumInstance(this);
}
}
class EnumProperty {
index = 0;
identifier = "";
instance = null;
constructor(index, identifier) {
this.index = index;
this.identifier = identifier;
}
}
export default {
EnumInstance: EnumInstance,
EnumTemplate: EnumTemplate,
EnumProperty: EnumProperty
};