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.domain.key.ConfigurationKey;
20  
21  /**
22   * Signals that a property has been encountered twice.
23   */
24  public class DuplicatePropertyException extends ConfigurationException
25  {
26    // ********************************* Fields *********************************
27  
28    // --- constants ------------------------------------------------------------
29  
30    /**
31     * The class version identifier.
32     * <p>
33     * The value of this constant is {@value}.
34     * </p>
35     */
36    private static final long serialVersionUID = 1L;
37  
38    // --- members --------------------------------------------------------------
39  
40    /**
41     * The currently active property.
42     *
43     * @serial
44     */
45    @MessageParam("currentPropertyName:name,currentPropertyValue:value,currentPropertySource:source")
46    private final Property currentProperty;
47  
48    /**
49     * The new encountered property with the same key.
50     *
51     * @serial
52     */
53    @MessageParam("newPropertyValue:value,newPropertySource:source")
54    private final Property newProperty;
55  
56    // ****************************** Initializer *******************************
57  
58    // ****************************** Constructors ******************************
59  
60    /**
61     * Default Constructor.
62     *
63     * @param key the key to the configuration that signaled problems.
64     * @param currentProperty the currently active property.
65     * @param newProperty the new encountered property with the same key.
66     */
67    public DuplicatePropertyException(final ConfigurationKey<?> key,
68        final Property currentProperty, final Property newProperty)
69    {
70      super(ConfigurationCode.DUPLICATE_PROPERTY, null, key);
71  
72      this.currentProperty = currentProperty;
73      this.newProperty = newProperty;
74    }
75  
76    // ****************************** Inner Classes *****************************
77  
78    // ********************************* Methods ********************************
79  
80    // --- init -----------------------------------------------------------------
81  
82    // --- get&set --------------------------------------------------------------
83  
84    /**
85     * Returns the currently active property.
86     *
87     * @return the currently active property.
88     */
89    public final Property getCurrentProperty()
90    {
91      return currentProperty;
92    }
93  
94    /**
95     * Returns the new encountered property with the same key.
96     *
97     * @return the new encountered property with the same key.
98     */
99    public final Property getNewProperty()
100   {
101     return newProperty;
102   }
103 
104   // --- business -------------------------------------------------------------
105 
106   // --- object basics --------------------------------------------------------
107 
108 }