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 de.smartics.exceptions.i18n.message.MessageParam;
19  import de.smartics.properties.api.config.codes.ConfigurationRootException;
20  import de.smartics.properties.api.config.codes.ConfigurationsCode;
21  import de.smartics.properties.api.config.domain.key.ConfigurationKey;
22  
23  /**
24   * Signals problems with a configuration.
25   */
26  public class ConfigurationException extends ConfigurationRootException
27  {
28    // ********************************* Fields *********************************
29  
30    // --- constants ------------------------------------------------------------
31  
32    /**
33     * The class version identifier.
34     * <p>
35     * The value of this constant is {@value}.
36     * </p>
37     */
38    private static final long serialVersionUID = 1L;
39  
40    // --- members --------------------------------------------------------------
41  
42    /**
43     * The key to the configuration that signaled problems.
44     *
45     * @serial
46     */
47    @MessageParam("configurationKey")
48    private final ConfigurationKey<?> key;
49  
50    // ****************************** Initializer *******************************
51  
52    // ****************************** Constructors ******************************
53  
54    /**
55     * Default constructor.
56     *
57     * @param code the error or exception code of the exception.
58     * @param key the key to the configuration that signaled problems.
59     */
60    public ConfigurationException(final ConfigurationsCode code,
61        final ConfigurationKey<?> key)
62    {
63      this(code, null, key);
64    }
65  
66    /**
67     * Default constructor.
68     *
69     * @param cause the cause (which is saved for later retrieval by the
70     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
71     *          and indicates that the cause is nonexistent or unknown.)
72     * @param code the error or exception code of the exception.
73     * @param key the key to the configuration that signaled problems.
74     */
75    public ConfigurationException(final ConfigurationsCode code,
76        final Throwable cause, final ConfigurationKey<?> key)
77    {
78      super(cause, code);
79      this.key = key;
80    }
81  
82    /**
83     * Default constructor with message bean.
84     *
85     * @param messageBean the message information for the exception.
86     */
87    public ConfigurationException(final ConfigurationMessageBean messageBean)
88    {
89      super(messageBean);
90      this.key = messageBean.getKey();
91    }
92  
93    // ****************************** Inner Classes *****************************
94  
95    // ********************************* Methods ********************************
96  
97    // --- init -----------------------------------------------------------------
98  
99    // --- get&set --------------------------------------------------------------
100 
101   /**
102    * Returns the key to the configuration that signaled problems.
103    *
104    * @return the key to the configuration that signaled problems.
105    */
106   public final ConfigurationKey<?> getKey()
107   {
108     return key;
109   }
110 
111   // --- business -------------------------------------------------------------
112 
113   // --- object basics --------------------------------------------------------
114 
115 }