Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EvaluationOperator |
|
| 2.5;2.5 | ||||
EvaluationOperator$Adapter |
|
| 2.5;2.5 |
1 | package org.kuali.rice.core.api.parameter; | |
2 | ||
3 | import org.kuali.rice.core.api.mo.common.Coded; | |
4 | import org.kuali.rice.core.api.util.jaxb.EnumStringAdapter; | |
5 | ||
6 | /** | |
7 | * Defines the possible evaluation operators that can be supported on system parameters. | |
8 | */ | |
9 | 2 | public enum EvaluationOperator implements Coded { |
10 | ||
11 | /** | |
12 | * Indicates that evaluation will determine if the value being tested in present | |
13 | * in the set of values defined on the parameter. If it is present in this set, | |
14 | * then evaluation will succeed. | |
15 | */ | |
16 | 1 | ALLOW("A"), |
17 | ||
18 | /** | |
19 | * Indicates that evaluation will determine if the value being tested is absent | |
20 | * from the set of values defined on the parameter. If it is absent from this | |
21 | * set, then the evaluation will succeed. | |
22 | */ | |
23 | 1 | DISALLOW("D"); |
24 | ||
25 | private final String code; | |
26 | ||
27 | 2 | EvaluationOperator(final String code) { |
28 | 2 | this.code = code; |
29 | 2 | } |
30 | ||
31 | /** | |
32 | * Returns the operator code for this evaluation operator. | |
33 | * | |
34 | * @return the code | |
35 | */ | |
36 | @Override | |
37 | public String getCode() { | |
38 | 5 | return code; |
39 | } | |
40 | ||
41 | public static EvaluationOperator fromCode(String code) { | |
42 | 1 | if (code == null) { |
43 | 1 | return null; |
44 | } | |
45 | 0 | for (EvaluationOperator operator : values()) { |
46 | 0 | if (operator.code.equals(code)) { |
47 | 0 | return operator; |
48 | } | |
49 | } | |
50 | 0 | throw new IllegalArgumentException("Failed to locate the EvaluationOperator with the given code: " + code); |
51 | } | |
52 | ||
53 | 2 | static final class Adapter extends EnumStringAdapter<EvaluationOperator> { |
54 | ||
55 | protected Class<EvaluationOperator> getEnumClass() { | |
56 | 3 | return EvaluationOperator.class; |
57 | } | |
58 | ||
59 | } | |
60 | ||
61 | } |