001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2008 Sun Microsystems, Inc.
026 */
027
028 package org.opends.server.admin;
029
030
031
032 /**
033 * A visitor of property definitions, in the style of the visitor
034 * design pattern. Classes implementing this interface can query
035 * property definitions in a type-safe manner when the kind of
036 * property definition is unknown at compile time. When a visitor is
037 * passed to a property definition's accept method, the corresponding
038 * visit method most applicable to that property definition is
039 * invoked.
040 * <p>
041 * Each <code>visitXXX</code> method is provided with a default
042 * implementation which calls
043 * {@link #visitUnknown(PropertyDefinition, Object)}. Sub-classes can
044 * override any or all of the methods to provide their own
045 * type-specific behavior.
046 *
047 * @param <R>
048 * The return type of this visitor's methods. Use
049 * {@link java.lang.Void} for visitors that do not need to
050 * return results.
051 * @param <P>
052 * The type of the additional parameter to this visitor's
053 * methods. Use {@link java.lang.Void} for visitors that do
054 * not need an additional parameter.
055 */
056 public abstract class PropertyDefinitionVisitor<R, P> {
057
058 /**
059 * Default constructor.
060 */
061 protected PropertyDefinitionVisitor() {
062 // No implementation required.
063 }
064
065
066
067 /**
068 * Visit a dseecompat Global ACI property definition.
069 *
070 * @param pd
071 * The Global ACI property definition to visit.
072 * @param p
073 * A visitor specified parameter.
074 * @return Returns a visitor specified result.
075 */
076 public R visitACI(ACIPropertyDefinition pd, P p) {
077 return visitUnknown(pd, p);
078 }
079
080
081
082 /**
083 * Visit an aggregation property definition.
084 *
085 * @param <C>
086 * The type of client managed object configuration that
087 * this aggregation property definition refers to.
088 * @param <S>
089 * The type of server managed object configuration that
090 * this aggregation property definition refers to.
091 * @param pd
092 * The aggregation property definition to visit.
093 * @param p
094 * A visitor specified parameter.
095 * @return Returns a visitor specified result.
096 */
097 public <C extends ConfigurationClient, S extends Configuration>
098 R visitAggregation(AggregationPropertyDefinition<C, S> pd, P p) {
099 return visitUnknown(pd, p);
100 }
101
102
103
104 /**
105 * Visit an attribute type property definition.
106 *
107 * @param pd
108 * The attribute type property definition to visit.
109 * @param p
110 * A visitor specified parameter.
111 * @return Returns a visitor specified result.
112 */
113 public R visitAttributeType(AttributeTypePropertyDefinition pd, P p) {
114 return visitUnknown(pd, p);
115 }
116
117
118
119 /**
120 * Visit a boolean property definition.
121 *
122 * @param pd
123 * The boolean property definition to visit.
124 * @param p
125 * A visitor specified parameter.
126 * @return Returns a visitor specified result.
127 */
128 public R visitBoolean(BooleanPropertyDefinition pd, P p) {
129 return visitUnknown(pd, p);
130 }
131
132
133
134 /**
135 * Visit a class property definition.
136 *
137 * @param pd
138 * The class property definition to visit.
139 * @param p
140 * A visitor specified parameter.
141 * @return Returns a visitor specified result.
142 */
143 public R visitClass(ClassPropertyDefinition pd, P p) {
144 return visitUnknown(pd, p);
145 }
146
147
148
149 /**
150 * Visit a DN property definition.
151 *
152 * @param pd
153 * The DN property definition to visit.
154 * @param p
155 * A visitor specified parameter.
156 * @return Returns a visitor specified result.
157 */
158 public R visitDN(DNPropertyDefinition pd, P p) {
159 return visitUnknown(pd, p);
160 }
161
162
163
164 /**
165 * Visit a duration property definition.
166 *
167 * @param pd
168 * The duration property definition to visit.
169 * @param p
170 * A visitor specified parameter.
171 * @return Returns a visitor specified result.
172 */
173 public R visitDuration(DurationPropertyDefinition pd, P p) {
174 return visitUnknown(pd, p);
175 }
176
177
178
179 /**
180 * Visit an enumeration property definition.
181 *
182 * @param <E>
183 * The enumeration that should be used for values of the
184 * property definition.
185 * @param pd
186 * The enumeration property definition to visit.
187 * @param p
188 * A visitor specified parameter.
189 * @return Returns a visitor specified result.
190 */
191 public <E extends Enum<E>> R visitEnum(EnumPropertyDefinition<E> pd, P p) {
192 return visitUnknown(pd, p);
193 }
194
195
196
197 /**
198 * Visit an integer property definition.
199 *
200 * @param pd
201 * The integer property definition to visit.
202 * @param p
203 * A visitor specified parameter.
204 * @return Returns a visitor specified result.
205 */
206 public R visitInteger(IntegerPropertyDefinition pd, P p) {
207 return visitUnknown(pd, p);
208 }
209
210
211
212 /**
213 * Visit a IP address property definition.
214 *
215 * @param pd
216 * The IP address property definition to visit.
217 * @param p
218 * A visitor specified parameter.
219 * @return Returns a visitor specified result.
220 */
221 public R visitIPAddress(IPAddressPropertyDefinition pd, P p) {
222 return visitUnknown(pd, p);
223 }
224
225
226
227 /**
228 * Visit a IP address mask property definition.
229 *
230 * @param pd
231 * The IP address mask property definition to visit.
232 * @param p
233 * A visitor specified parameter.
234 * @return Returns a visitor specified result.
235 */
236 public R visitIPAddressMask(IPAddressMaskPropertyDefinition pd, P p) {
237 return visitUnknown(pd, p);
238 }
239
240
241 /**
242 * Visit a size property definition.
243 *
244 * @param pd
245 * The size property definition to visit.
246 * @param p
247 * A visitor specified parameter.
248 * @return Returns a visitor specified result.
249 */
250 public R visitSize(SizePropertyDefinition pd, P p) {
251 return visitUnknown(pd, p);
252 }
253
254
255
256 /**
257 * Visit a string property definition.
258 *
259 * @param pd
260 * The string property definition to visit.
261 * @param p
262 * A visitor specified parameter.
263 * @return Returns a visitor specified result.
264 */
265 public R visitString(StringPropertyDefinition pd, P p) {
266 return visitUnknown(pd, p);
267 }
268
269
270
271 /**
272 * Visit an unknown type of property definition. Implementations of
273 * this method can provide default behavior for unknown property
274 * definition types.
275 * <p>
276 * The default implementation of this method throws an
277 * {@link UnknownPropertyDefinitionException}. Sub-classes can
278 * override this method with their own default behavior.
279 *
280 * @param <T>
281 * The type of the underlying property.
282 * @param pd
283 * The property definition to visit.
284 * @param p
285 * A visitor specified parameter.
286 * @return Returns a visitor specified result.
287 * @throws UnknownPropertyDefinitionException
288 * Visitor implementations may optionally throw this
289 * exception.
290 */
291 public <T> R visitUnknown(PropertyDefinition<T> pd, P p)
292 throws UnknownPropertyDefinitionException {
293 throw new UnknownPropertyDefinitionException(pd, p);
294 }
295
296 }