View Javadoc

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