Skip to content

Commit d854d1c

Browse files
authored
Merge pull request #28 from RUB-NDS/ansiColor
Added function to get AnsiColor from String
2 parents a0b0e5a + 598a141 commit d854d1c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main/java/de/rub/nds/tlsscanner/constants/AnsiColor.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
*/
99
package de.rub.nds.tlsscanner.constants;
1010

11+
import java.util.HashMap;
12+
import java.util.Map;
13+
1114
/**
1215
*
1316
* @author Robert Merget <[email protected]>
@@ -36,10 +39,24 @@ public enum AnsiColor {
3639

3740
private String code;
3841

42+
private static final Map<String, AnsiColor> MAP;
43+
3944
private AnsiColor(String code) {
4045
this.code = code;
4146
}
47+
48+
static {
49+
MAP = new HashMap<>();
50+
for (AnsiColor c : AnsiColor.values()) {
51+
MAP.put(c.code, c);
52+
}
53+
}
4254

55+
public static AnsiColor getAnsiColor(String code) {
56+
return MAP.get(code);
57+
}
58+
59+
4360
public String getCode() {
4461
return code;
4562
}

0 commit comments

Comments
 (0)