Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PropositionType |
|
| 2.5;2.5 | ||||
PropositionType$Adapter |
|
| 2.5;2.5 |
1 | /** | |
2 | * Copyright 2005-2011 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.krms.api.repository.proposition; | |
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.HashSet; | |
22 | import java.util.Set; | |
23 | ||
24 | /** | |
25 | * TODO... | |
26 | * | |
27 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
28 | * | |
29 | */ | |
30 | 0 | public enum PropositionType implements Coded { |
31 | ||
32 | 0 | COMPOUND("C"), |
33 | 0 | SIMPLE("S"); |
34 | ||
35 | private final String code; | |
36 | ||
37 | 0 | private PropositionType(String code) { |
38 | 0 | this.code = code; |
39 | 0 | } |
40 | ||
41 | /** | |
42 | * Returns the operator code for this evaluation operator. | |
43 | * | |
44 | * @return the operatorCode | |
45 | */ | |
46 | @Override | |
47 | public String getCode() { | |
48 | 0 | return code; |
49 | } | |
50 | ||
51 | 0 | public static final Set<String> VALID_TYPE_CODES = new HashSet<String>(); |
52 | static { | |
53 | 0 | for (PropositionType propositionType : values()) { |
54 | 0 | VALID_TYPE_CODES.add(propositionType.getCode()); |
55 | } | |
56 | 0 | } |
57 | ||
58 | public static PropositionType fromCode(String code) { | |
59 | 0 | if (code == null) { |
60 | 0 | return null; |
61 | } | |
62 | 0 | for (PropositionType propositionType : values()) { |
63 | 0 | if (propositionType.code.equals(code)) { |
64 | 0 | return propositionType; |
65 | } | |
66 | } | |
67 | 0 | throw new IllegalArgumentException("Failed to locate the PropositionType with the given code: " + code); |
68 | } | |
69 | ||
70 | 0 | static final class Adapter extends EnumStringAdapter<PropositionType> { |
71 | ||
72 | protected Class<PropositionType> getEnumClass() { | |
73 | 0 | return PropositionType.class; |
74 | } | |
75 | ||
76 | } | |
77 | ||
78 | } |