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
26
27
28
29
30 public enum LogicalOperator implements Coded {
31
32
33
34
35 AND("&"),
36
37
38
39
40 OR("|");
41
42 private final String code;
43
44
45
46
47
48 private LogicalOperator(String code){
49 this.code = code;
50 }
51
52 @Override
53 public String getCode(){
54 return code;
55 }
56
57
58
59
60 public static final Collection<String> OP_CODES =
61 Collections.unmodifiableCollection(Arrays.asList(AND.code, OR.code));
62
63
64
65
66 public static final Collection<String> OP_CODE_NAMES =
67 Collections.unmodifiableCollection(Arrays.asList(AND.name(), OR.name()));
68
69
70
71
72
73
74
75 public static LogicalOperator fromCode(String code) {
76 if (code == null) {
77 return null;
78 }
79 for (LogicalOperator logicalOperator : values()) {
80 if (logicalOperator.code.equals(code)) {
81 return logicalOperator;
82 }
83 }
84 throw new IllegalArgumentException("Failed to locate the LogicalOperator with the given code: " + code);
85 }
86
87 @Override
88 public String toString(){
89 return code;
90 }
91
92 static final class Adapter extends EnumStringAdapter<LogicalOperator> {
93 @Override
94 protected Class<LogicalOperator> getEnumClass() {
95 return LogicalOperator.class;
96 }
97
98 }
99
100 }