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.CONFIG_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 ConfigCode implements PropertiesCode
27 {
28 // ***************************** Enumeration ******************************
29
30 /**
31 * Signals that a configuration file cannot be found.
32 */
33 @MessageParamsDescriptor(ConfigMessageBean.class)
34 CONFIG_FILE_NOT_FOUND(0),
35
36 /**
37 * Signals that a configuration file cannot be read.
38 */
39 @MessageParamsDescriptor(ConfigMessageBean.class)
40 CONFIG_FILE_CANNOT_BE_READ(1),
41
42 /**
43 * Signals that the parser cannot parse the given definitions file since the
44 * namespace is not as expected.
45 */
46 @MessageParamsDescriptor(ConfigMessageBean.class)
47 WRONG_NAMESPACE(2),
48
49 /**
50 * Signals that a configuration key within a definitions configuration file
51 * is declared as default key twice.
52 */
53 @MessageParamsDescriptor(ConfigMessageBean.class)
54 DUPLICATE_DEFAULT_KEY(10);
55
56 // ******************************** Fields ********************************
57
58 // --- constants ----------------------------------------------------------
59
60 // --- members ------------------------------------------------------------
61
62 /**
63 * The code information.
64 */
65 private final NumberCodeInfo info;
66
67 // ***************************** Constructors *****************************
68
69 /**
70 * Default constructor.
71 *
72 * @param minorNumber the minor part of the error code.
73 */
74 private ConfigCode(final Integer minorNumber)
75 {
76 this.info = new NumberCodeInfo("Config", CONFIG_CODE_START, minorNumber);
77 }
78
79 // ******************************** Methods *******************************
80
81 // --- init ---------------------------------------------------------------
82
83 // --- get&set ------------------------------------------------------------
84
85 @Override
86 public String getCode()
87 {
88 return info.getCode();
89 }
90
91 @Override
92 public String getComponentId()
93 {
94 return info.getComponentId();
95 }
96
97 @Override
98 public String getDisplayId()
99 {
100 return info.toString();
101 }
102
103 @Override
104 public Integer getMajorNumber()
105 {
106 return info.getMajorNumber();
107 }
108
109 @Override
110 public Integer getMinorNumber()
111 {
112 return info.getMinorNumber();
113 }
114
115 // --- business -----------------------------------------------------------
116
117 // --- object basics ------------------------------------------------------
118
119 /**
120 * Returns the string representation of the object.
121 *
122 * @return the string representation of the object.
123 */
124 @Override
125 public String toString()
126 {
127 return getDisplayId();
128 }
129 }