1 | /* |
2 | * jDTAUS Core API |
3 | * Copyright (C) 2005 Christian Schulte |
4 | * <cs@schulte.it> |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Lesser General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2.1 of the License, or any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public |
17 | * License along with this library; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19 | * |
20 | */ |
21 | package org.jdtaus.core.container; |
22 | |
23 | import java.util.Locale; |
24 | |
25 | /** |
26 | * Gets thrown for property overwrite constraint violations. |
27 | * <p>A {@code Dependency} is allowed to provide values for any properties |
28 | * declared for its specification only if the specification applies to scope |
29 | * {@code SCOPE_MULTITON}. An implementation must provide values for all |
30 | * properties declared for its implemented specifications. This exception gets |
31 | * thrown for any violations to these restrictions.</p> |
32 | * |
33 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
34 | * @version $JDTAUS: PropertyOverwriteConstraintException.java 8641 2012-09-27 06:45:17Z schulte $ |
35 | * |
36 | * @see Implementation#getProperties() |
37 | * @see Dependency#getProperties() |
38 | */ |
39 | public class PropertyOverwriteConstraintException extends IllegalStateException |
40 | { |
41 | //--Constants--------------------------------------------------------------- |
42 | |
43 | /** Serial version UID for backwards compatibility with 1.2.x classes. */ |
44 | private static final long serialVersionUID = -6382737345293763298L; |
45 | |
46 | //---------------------------------------------------------------Constants-- |
47 | //--Constructors------------------------------------------------------------ |
48 | |
49 | /** |
50 | * Creates a new {@code PropertyOverwriteConstraintException} instance |
51 | * taking the identifier of an implementation defining a dependency |
52 | * providing property values although the specification does not apply to |
53 | * the multiton scope. |
54 | * |
55 | * @param implementationIdentifier identifier of the implementation defining |
56 | * a dependency violating the constraint. |
57 | * @param dependencyName name of the dependency defined for the |
58 | * implementation identified by {@code implementationIdentifier} violating |
59 | * the constraint. |
60 | */ |
61 | public PropertyOverwriteConstraintException( |
62 | final String implementationIdentifier, final String dependencyName ) |
63 | { |
64 | super( PropertyOverwriteConstraintExceptionBundle.getInstance(). |
65 | getPropertyOverwriteConstraintMessage( Locale.getDefault(), |
66 | implementationIdentifier, |
67 | dependencyName ) ); |
68 | |
69 | this.implementationIdentifier = implementationIdentifier; |
70 | this.specificationIdentifier = null; |
71 | this.dependencyName = dependencyName; |
72 | this.propertyName = null; |
73 | } |
74 | |
75 | /** |
76 | * Creates a new {@code PropertyOverwriteConstraintException} instance |
77 | * taking the identifier of an implementation not implementing a |
78 | * specification property together with information regarding the |
79 | * unimplemented property. |
80 | * |
81 | * @param implementationIdentifier identifier of the implementation not |
82 | * implementing a specification property. |
83 | * @param specificationIdentifier identifier of the specification an |
84 | * implementation does not implement a property of. |
85 | * @param propertyName name of the unimplemented property. |
86 | */ |
87 | public PropertyOverwriteConstraintException( |
88 | final String implementationIdentifier, |
89 | final String specificationIdentifier, final String propertyName ) |
90 | { |
91 | super( PropertyOverwriteConstraintExceptionBundle.getInstance(). |
92 | getPropertyNotImplementedMessage( Locale.getDefault(), |
93 | implementationIdentifier, |
94 | specificationIdentifier, |
95 | propertyName ) ); |
96 | |
97 | this.implementationIdentifier = implementationIdentifier; |
98 | this.specificationIdentifier = specificationIdentifier; |
99 | this.propertyName = propertyName; |
100 | this.dependencyName = null; |
101 | } |
102 | |
103 | //------------------------------------------------------------Constructors-- |
104 | //--PropertyOverwriteConstraintException------------------------------------ |
105 | |
106 | /** |
107 | * Identifier of the implementation defining a dependency violating the |
108 | * constraint. |
109 | * @serial |
110 | */ |
111 | private final String implementationIdentifier; |
112 | |
113 | /** |
114 | * Identifier of the specification defining a property not implemented by |
115 | * the implementation. |
116 | * @serial |
117 | */ |
118 | private final String specificationIdentifier; |
119 | |
120 | /** |
121 | * Name of the dependency defined for the implementation identified by |
122 | * property {@code implementationIdentifier} violating the constraint. |
123 | * @serial |
124 | */ |
125 | private final String dependencyName; |
126 | |
127 | /** |
128 | * Name of the property not implemented by the implementation. |
129 | * @serial |
130 | */ |
131 | private final String propertyName; |
132 | |
133 | /** |
134 | * Gets the identifier of the implementation defining a dependency |
135 | * violating the constraint. |
136 | * |
137 | * @return identifier of the implementation defining a dependency |
138 | * violating the constraint. |
139 | */ |
140 | public String getImplementationIdentifier() |
141 | { |
142 | return this.implementationIdentifier; |
143 | } |
144 | |
145 | /** |
146 | * Gets the identifier of the specification defining a property not |
147 | * implemented by the implementation. |
148 | * |
149 | * @return identifier of the specification defining a property not |
150 | * implemented by the implementation or {@code null}. |
151 | */ |
152 | public String getSpecificationIdentifier() |
153 | { |
154 | return this.specificationIdentifier; |
155 | } |
156 | |
157 | /** |
158 | * Gets the name of the dependency defined for the implementation identified |
159 | * by the value of property {@code implementationIdentifier} violating the |
160 | * constraint. |
161 | * |
162 | * @return name of the dependency defined for the implementation identified |
163 | * by the value of property {@code implementationIdentifier} violating the |
164 | * constraint or {@code null}. |
165 | */ |
166 | public String getDependencyName() |
167 | { |
168 | return this.dependencyName; |
169 | } |
170 | |
171 | /** |
172 | * Gets the name of the property not implemented by the implementation. |
173 | * |
174 | * @return name of the property not implemented by the implementation or |
175 | * {@code null}. |
176 | */ |
177 | public String getPropertyName() |
178 | { |
179 | return this.propertyName; |
180 | } |
181 | |
182 | //------------------------------------PropertyOverwriteConstraintException-- |
183 | } |