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.spi.config.transfer;
17  
18  import static de.smartics.properties.api.config.codes.LibraryCodeNumbers.TRANSFER_CODE_START;
19  import de.smartics.exceptions.code.NumberCodeInfo;
20  import de.smartics.exceptions.i18n.message.MessageParamsDescriptor;
21  import de.smartics.properties.api.config.codes.ConfigurationsCode;
22  
23  /**
24   * Codes dealing with property problems.
25   */
26  public enum TransferCode implements ConfigurationsCode
27  {
28    // ***************************** Enumeration ******************************
29  
30    /**
31     * Cannot find a configuration key for a given properties file.
32     */
33    @MessageParamsDescriptor(NoConfigurationKeyForPropertiesMessageBean.class)
34    NO_CONFIG_KEY_FOR_PROPERTIES(0),
35  
36    /**
37     * Cannot read {@code definition.xml} from properties provider.
38     */
39    @MessageParamsDescriptor(DefinitionXmlMessageBean.class)
40    NO_DEFINITION_XML(1),
41  
42    /**
43     * Cannot construct a valid URL to the {@code definition.xml}.
44     */
45    @MessageParamsDescriptor(DefinitionXmlMessageBean.class)
46    MALFORMED_URL_TO_DEFINITION_XML(2);
47  
48    // ******************************** Fields ********************************
49  
50    // --- constants ----------------------------------------------------------
51  
52    // --- members ------------------------------------------------------------
53  
54    /**
55     * The code information.
56     */
57    private final NumberCodeInfo info;
58  
59    // ***************************** Constructors *****************************
60  
61    /**
62     * Default constructor.
63     *
64     * @param minorNumber the minor part of the error code.
65     */
66    private TransferCode(final Integer minorNumber)
67    {
68      this.info =
69          new NumberCodeInfo("Transfer", TRANSFER_CODE_START, minorNumber);
70    }
71  
72    // ******************************** Methods *******************************
73  
74    // --- init ---------------------------------------------------------------
75  
76    // --- get&set ------------------------------------------------------------
77  
78    @Override
79    public String getCode()
80    {
81      return info.getCode();
82    }
83  
84    @Override
85    public String getComponentId()
86    {
87      return info.getComponentId();
88    }
89  
90    @Override
91    public String getDisplayId()
92    {
93      return info.toString();
94    }
95  
96    @Override
97    public Integer getMajorNumber()
98    {
99      return info.getMajorNumber();
100   }
101 
102   @Override
103   public Integer getMinorNumber()
104   {
105     return info.getMinorNumber();
106   }
107 
108   // --- business -----------------------------------------------------------
109 
110   // --- object basics ------------------------------------------------------
111 
112   /**
113    * Returns the string representation of the object.
114    *
115    * @return the string representation of the object.
116    */
117   @Override
118   public String toString()
119   {
120     return getDisplayId();
121   }
122 }