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 public static final Collection<String> OP_CODES =
58 Collections.unmodifiableCollection(Arrays.asList(AND.code, OR.code));
59
60 public static final Collection<String> OP_CODE_NAMES =
61 Collections.unmodifiableCollection(Arrays.asList(AND.name(), OR.name()));
62
63
64
65
66
67
68
69 public static LogicalOperator fromCode(String code) {
70 if (code == null) {
71 return null;
72 }
73 for (LogicalOperator logicalOperator : values()) {
74 if (logicalOperator.code.equals(code)) {
75 return logicalOperator;
76 }
77 }
78 throw new IllegalArgumentException("Failed to locate the LogicalOperator with the given code: " + code);
79 }
80
81 @Override
82 public String toString(){
83 return code;
84 }
85
86 static final class Adapter extends EnumStringAdapter<LogicalOperator> {
87 @Override
88 protected Class<LogicalOperator> getEnumClass() {
89 return LogicalOperator.class;
90 }
91
92 }
93
94 }