1 /*
2 * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3 *
4 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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 de.smartics.properties.api.core.domain;
17
18 import static de.smartics.properties.api.core.app.LibraryCodeNumbers.PROPERTY_CODE_START;
19 import de.smartics.exceptions.code.NumberCodeInfo;
20 import de.smartics.exceptions.i18n.message.MessageParamsDescriptor;
21 import de.smartics.properties.api.core.app.PropertiesCode;
22
23 /**
24 * Codes dealing with property problems.
25 */
26 public enum PropertyCode implements PropertiesCode
27 {
28 // ***************************** Enumeration ******************************
29
30 /**
31 * Placeholders in property value cannot be resolved.
32 */
33 @MessageParamsDescriptor(PropertyExpressionMessageBean.class)
34 RESOLVE_PROBLEM(0),
35
36 /**
37 * The property is not valid.
38 */
39 @MessageParamsDescriptor(PropertyValueMessageBean.class)
40 CONVERSION_PROBLEM(1),
41
42 /**
43 * The property is not valid.
44 */
45 @MessageParamsDescriptor(PropertyValidationMessageBean.class)
46 INVALID_VALUE(2),
47
48 /**
49 * A read-only property was requested to be updated.
50 */
51 @MessageParamsDescriptor(PropertyValidationMessageBean.class)
52 READ_ONLY(10),
53
54 /**
55 * Securing a property value failed.
56 */
57 @MessageParamsDescriptor(PropertyDescriptorMessageBean.class)
58 SECURITY(11),
59
60 /**
61 * Duplicate property declaration.
62 */
63 @MessageParamsDescriptor(PropertyDescriptorClashingMessageBean.class)
64 DUPLICATE_DECLARATION(20),
65
66 /**
67 * Signals more than one duplicate property declarations.
68 */
69 @MessageParamsDescriptor(DuplicatePropertyDeclarationsException.class)
70 DUPLICATE_DECLARATIONS(21);
71
72
73 // ******************************** Fields ********************************
74
75 // --- constants ----------------------------------------------------------
76
77 // --- members ------------------------------------------------------------
78
79 /**
80 * The code information.
81 */
82 private final NumberCodeInfo info;
83
84 // ***************************** Constructors *****************************
85
86 /**
87 * Default constructor.
88 *
89 * @param minorNumber the minor part of the error code.
90 */
91 private PropertyCode(final Integer minorNumber)
92 {
93 this.info =
94 new NumberCodeInfo("Property", PROPERTY_CODE_START, minorNumber);
95 }
96
97 // ******************************** Methods *******************************
98
99 // --- init ---------------------------------------------------------------
100
101 // --- get&set ------------------------------------------------------------
102
103 @Override
104 public String getCode()
105 {
106 return info.getCode();
107 }
108
109 @Override
110 public String getComponentId()
111 {
112 return info.getComponentId();
113 }
114
115 @Override
116 public String getDisplayId()
117 {
118 return info.toString();
119 }
120
121 @Override
122 public Integer getMajorNumber()
123 {
124 return info.getMajorNumber();
125 }
126
127 @Override
128 public Integer getMinorNumber()
129 {
130 return info.getMinorNumber();
131 }
132
133 // --- business -----------------------------------------------------------
134
135 // --- object basics ------------------------------------------------------
136
137 /**
138 * Returns the string representation of the object.
139 *
140 * @return the string representation of the object.
141 */
142 @Override
143 public String toString()
144 {
145 return getDisplayId();
146 }
147 }