1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krms.api.repository; |
17 | |
|
18 | |
import org.kuali.rice.core.api.mo.common.Coded; |
19 | |
import org.kuali.rice.core.api.util.jaxb.EnumStringAdapter; |
20 | |
|
21 | |
import java.util.Arrays; |
22 | |
import java.util.Collection; |
23 | |
import java.util.Collections; |
24 | |
|
25 | 0 | public enum LogicalOperator implements Coded { |
26 | |
|
27 | 0 | AND("&"), |
28 | 0 | OR("|"); |
29 | |
|
30 | |
private final String code; |
31 | |
|
32 | 0 | private LogicalOperator(String code){ |
33 | 0 | this.code = code; |
34 | 0 | } |
35 | |
|
36 | |
@Override |
37 | |
public String getCode(){ |
38 | 0 | return code; |
39 | |
} |
40 | |
|
41 | 0 | public static final Collection<String> OP_CODES = |
42 | |
Collections.unmodifiableCollection(Arrays.asList(AND.code, OR.code)); |
43 | |
|
44 | 0 | public static final Collection<String> OP_CODE_NAMES = |
45 | |
Collections.unmodifiableCollection(Arrays.asList(AND.name(), OR.name())); |
46 | |
|
47 | |
public static LogicalOperator fromCode(String code) { |
48 | 0 | if (code == null) { |
49 | 0 | return null; |
50 | |
} |
51 | 0 | for (LogicalOperator logicalOperator : values()) { |
52 | 0 | if (logicalOperator.code.equals(code)) { |
53 | 0 | return logicalOperator; |
54 | |
} |
55 | |
} |
56 | 0 | throw new IllegalArgumentException("Failed to locate the LogicalOperator with the given code: " + code); |
57 | |
} |
58 | |
|
59 | |
@Override |
60 | |
public String toString(){ |
61 | 0 | return code; |
62 | |
} |
63 | |
|
64 | 0 | static final class Adapter extends EnumStringAdapter<LogicalOperator> { |
65 | |
|
66 | |
protected Class<LogicalOperator> getEnumClass() { |
67 | 0 | return LogicalOperator.class; |
68 | |
} |
69 | |
|
70 | |
} |
71 | |
|
72 | |
} |