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.api.config.domain;
17  
18  import static de.smartics.properties.api.config.codes.LibraryCodeNumbers.PROPERTY_STORE_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 store problems.
25   */
26  public enum PropertyStoreCode implements ConfigurationsCode
27  {
28    // ***************************** Enumeration ******************************
29  
30    /**
31     * Failed to get property from store.
32     */
33    @MessageParamsDescriptor(PropertyStoreMessageBean.class)
34    CANNOT_GET_PROPERTY(0),
35  
36    /**
37     * Failed to get property collection from store.
38     */
39    @MessageParamsDescriptor(PropertyStoreMessageBean.class)
40    CANNOT_GET_PROPERTY_COLLECTION(1),
41  
42    /**
43     * Failed to store property in store.
44     */
45    @MessageParamsDescriptor(PropertyStoreMessageBean.class)
46    CANNOT_SET_PROPERTY(2),
47  
48    /**
49     * Failed to delete property from store.
50     */
51    @MessageParamsDescriptor(PropertyStoreMessageBean.class)
52    CANNOT_DELETE_PROPERTY(3);
53  
54    // ******************************** Fields ********************************
55  
56    // --- constants ----------------------------------------------------------
57  
58    // --- members ------------------------------------------------------------
59  
60    /**
61     * The code information.
62     */
63    private final NumberCodeInfo info;
64  
65    // ***************************** Constructors *****************************
66  
67    /**
68     * Default constructor.
69     *
70     * @param minorNumber the minor part of the error code.
71     */
72    private PropertyStoreCode(final Integer minorNumber)
73    {
74      this.info =
75          new NumberCodeInfo("Store", PROPERTY_STORE_CODE_START, minorNumber);
76    }
77  
78    // ******************************** Methods *******************************
79  
80    // --- init ---------------------------------------------------------------
81  
82    // --- get&set ------------------------------------------------------------
83  
84    @Override
85    public String getCode()
86    {
87      return info.getCode();
88    }
89  
90    @Override
91    public String getComponentId()
92    {
93      return info.getComponentId();
94    }
95  
96    @Override
97    public String getDisplayId()
98    {
99      return info.toString();
100   }
101 
102   @Override
103   public Integer getMajorNumber()
104   {
105     return info.getMajorNumber();
106   }
107 
108   @Override
109   public Integer getMinorNumber()
110   {
111     return info.getMinorNumber();
112   }
113 
114   // --- business -----------------------------------------------------------
115 
116   // --- object basics ------------------------------------------------------
117 
118   /**
119    * Returns the string representation of the object.
120    *
121    * @return the string representation of the object.
122    */
123   @Override
124   public String toString()
125   {
126     return getDisplayId();
127   }
128 }