File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
model/src/main/java/com/basistech/rosette/apimodel Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 1616
1717package com .basistech .rosette .apimodel ;
1818
19- import java .util .EnumSet ;
19+ import java .util .Arrays ;
20+ import java .util .Map ;
21+ import java .util .function .Function ;
22+ import java .util .stream .Collectors ;
2023
2124public enum EventsNegationOption {
2225 IGNORE ("Ignore" ),
2326 BOTH ("Both" ),
2427 ONLY_POSITIVE ("Only positive" ),
2528 ONLY_NEGATIVE ("Only negative" );
2629
30+ private static final Map <String , EventsNegationOption > STRING_KEYS ;
31+
32+ static {
33+ STRING_KEYS = Arrays .stream (EventsNegationOption .values ())
34+ .collect (Collectors .toMap (
35+ value -> value .toString ().toLowerCase (),
36+ Function .identity ()
37+ ));
38+ }
39+
2740 private final String label ;
2841
2942 EventsNegationOption (String label ) {
3043 this .label = label ;
3144 }
3245
3346 public static EventsNegationOption forValue (String value ) {
34- for (EventsNegationOption negationOption : EnumSet .allOf (EventsNegationOption .class )) {
35- if (negationOption .toString ().equalsIgnoreCase (value )) {
36- return negationOption ;
37- }
38- }
39- throw new IllegalArgumentException ("invalid events negation option: " + value );
47+ return STRING_KEYS .get (value .toLowerCase ());
4048 }
4149
4250 @ Override
You can’t perform that action at this time.
0 commit comments