-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathState.java
More file actions
47 lines (36 loc) · 1.21 KB
/
Copy pathState.java
File metadata and controls
47 lines (36 loc) · 1.21 KB
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
package com.checkmarx.eclipse.enums;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
public class State {
private static final Map<String, State> STATES = new LinkedHashMap<>();
// Predefined states
public static final State TO_VERIFY = new State("TO_VERIFY");
public static final State NOT_EXPLOITABLE = new State("NOT_EXPLOITABLE");
public static final State PROPOSED_NOT_EXPLOITABLE = new State("PROPOSED_NOT_EXPLOITABLE");
public static final State CONFIRMED = new State("CONFIRMED");
public static final State NOT_IGNORED = new State("NOT_IGNORED");
public static final State IGNORED = new State("IGNORED");
public static final State URGENT = new State("URGENT");
private final String name;
private State(String name) {
this.name = name;
STATES.put(name, this);
}
public String getName() {
return name;
}
public static State of(String name) {
return STATES.computeIfAbsent(name, State::new); // register custom states dynamically
}
public static State getState(String name) {
return STATES.get(name);
}
public static Map<String, State> values() {
return Collections.unmodifiableMap(STATES);
}
@Override
public String toString() {
return name;
}
}