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.resolve;
17  
18  import java.util.List;
19  
20  /**
21   * Signals that a property is not resolvable.
22   */
23  public class UnresolvablePropertyException extends RuntimeException
24  {
25    // ********************************* Fields *********************************
26  
27    // --- constants ------------------------------------------------------------
28  
29    /**
30     * The class version identifier.
31     * <p>
32     * The value of this constant is {@value}.
33     * </p>
34     */
35    private static final long serialVersionUID = 1L;
36  
37    // --- members --------------------------------------------------------------
38  
39    /**
40     * The key to the unresolvable property.
41     *
42     * @serial
43     */
44    private final String propertyKey;
45  
46    /**
47     * The path to the recursive point.
48     *
49     * @serial
50     */
51    private final List<String> path;
52  
53    // ****************************** Initializer *******************************
54  
55    // ****************************** Constructors ******************************
56  
57    /**
58     * Convenience constructor without root cause.
59     *
60     * @param propertyKey the key to the unknown property.
61     * @param path the path to the recursive point.
62     */
63    public UnresolvablePropertyException(final String propertyKey,
64        final List<String> path)
65    {
66      this(null, propertyKey, path);
67    }
68  
69    /**
70     * Default Constructor.
71     *
72     * @param cause the cause (which is saved for later retrieval by the
73     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
74     *          and indicates that the cause is nonexistent or unknown.)
75     * @param propertyKey the key to the unknown property.
76     * @param path the path to the recursive point.
77     */
78    public UnresolvablePropertyException(final Throwable cause,
79        final String propertyKey, final List<String> path)
80    {
81      super("Property '" + propertyKey + "' is not resolvable: " + path, cause);
82      this.propertyKey = propertyKey;
83      this.path = path;
84    }
85  
86    // ****************************** Inner Classes *****************************
87  
88    // ********************************* Methods ********************************
89  
90    // --- init -----------------------------------------------------------------
91  
92    // --- get&set --------------------------------------------------------------
93  
94    /**
95     * Returns the key to the unknown property.
96     *
97     * @return the key to the unknown property.
98     */
99    public final String getPropertyKey()
100   {
101     return propertyKey;
102   }
103 
104   /**
105    * Returns the path to the recursive point.
106    *
107    * @return the path to the recursive point.
108    */
109   public final List<String> getPath()
110   {
111     return path;
112   }
113 
114   // --- business -------------------------------------------------------------
115 
116   // --- object basics --------------------------------------------------------
117 
118 }