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.properties.api.config.domain.key.ConfigurationKey;
19  
20  /**
21   * Signals that a property is unknown.
22   */
23  public class UnknownPropertyException extends ConfigurationException
24  {
25    // ********************************* Fields *********************************
26  
27    // --- constants ------------------------------------------------------------
28  
29    /**
30     * The class version identifier.
31     * <p>
32     * The value of this constant is {@value}.
33     */
34    private static final long serialVersionUID = 1L;
35  
36    // --- members --------------------------------------------------------------
37  
38    /**
39     * The key to the unknown property.
40     *
41     * @serial
42     */
43    private final String propertyKey;
44  
45    // ****************************** Initializer *******************************
46  
47    // ****************************** Constructors ******************************
48  
49    /**
50     * Convenience constructor without root cause.
51     *
52     * @param key the key to the configuration that signaled problems.
53     * @param propertyKey the key to the unknown property.
54     */
55    public UnknownPropertyException(final ConfigurationKey key,
56        final String propertyKey)
57    {
58      this(null, key, propertyKey);
59    }
60  
61    /**
62     * Default Constructor.
63     *
64     * @param cause the cause (which is saved for later retrieval by the
65     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
66     *          and indicates that the cause is nonexistent or unknown.)
67     * @param key the key to the configuration that signaled problems.
68     * @param propertyKey the key to the unknown property.
69     */
70    public UnknownPropertyException(final Throwable cause,
71        final ConfigurationKey key, final String propertyKey)
72    {
73      super("Property '" + propertyKey + "' is not known in configuration '"
74            + key + "'.", cause, key);
75      this.propertyKey = propertyKey;
76    }
77  
78    // ****************************** Inner Classes *****************************
79  
80    // ********************************* Methods ********************************
81  
82    // --- init -----------------------------------------------------------------
83  
84    // --- get&set --------------------------------------------------------------
85  
86    /**
87     * Returns the key to the unknown property.
88     *
89     * @return the key to the unknown property.
90     */
91    public final String getPropertyKey()
92    {
93      return propertyKey;
94    }
95  
96    // --- business -------------------------------------------------------------
97  
98    // --- object basics --------------------------------------------------------
99  
100 }