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.resource.domain;
17
18 import static de.smartics.properties.resource.app.LibraryCodeNumbers.RESOURCE_CODE_START;
19 import de.smartics.exceptions.code.NumberCodeInfo;
20 import de.smartics.exceptions.i18n.message.MessageParamsDescriptor;
21 import de.smartics.properties.api.core.domain.TypeProblemMessageBean;
22 import de.smartics.properties.resource.app.ResourcesCode;
23
24 /**
25 * Codes dealing with property problems.
26 */
27 public enum ResourceCode implements ResourcesCode
28 {
29 // ***************************** Enumeration ******************************
30
31 /**
32 * Placeholder only.
33 */
34 @MessageParamsDescriptor(TypeProblemMessageBean.class)
35 GENERIC(0);
36
37 // ******************************** Fields ********************************
38
39 // --- constants ----------------------------------------------------------
40
41 // --- members ------------------------------------------------------------
42
43 /**
44 * The code information.
45 */
46 private final NumberCodeInfo info;
47
48 // ***************************** Constructors *****************************
49
50 /**
51 * Default constructor.
52 *
53 * @param minorNumber the minor part of the error code.
54 */
55 private ResourceCode(final Integer minorNumber)
56 {
57 this.info =
58 new NumberCodeInfo("Resource", RESOURCE_CODE_START, minorNumber);
59 }
60
61 // ******************************** Methods *******************************
62
63 // --- init ---------------------------------------------------------------
64
65 // --- get&set ------------------------------------------------------------
66
67 @Override
68 public String getCode()
69 {
70 return info.getCode();
71 }
72
73 @Override
74 public String getComponentId()
75 {
76 return info.getComponentId();
77 }
78
79 @Override
80 public String getDisplayId()
81 {
82 return info.toString();
83 }
84
85 @Override
86 public Integer getMajorNumber()
87 {
88 return info.getMajorNumber();
89 }
90
91 @Override
92 public Integer getMinorNumber()
93 {
94 return info.getMinorNumber();
95 }
96
97 // --- business -----------------------------------------------------------
98
99 // --- object basics ------------------------------------------------------
100
101 /**
102 * Returns the string representation of the object.
103 *
104 * @return the string representation of the object.
105 */
106 @Override
107 public String toString()
108 {
109 return getDisplayId();
110 }
111 }