View Javadoc

1   /*
2    * Copyright 2004-2005 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * 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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package net.sf.composite.specialize;
17  
18  /***
19   * Constructs specialized instances of a composite using its components. The
20   * specialized instance is constructed by gathering all the components of the
21   * original composite that are of the designated specialization type. The
22   * specialized instance may be a subtype of the original composite.
23   * 
24   * @author Matt Sgarlata
25   * @since Mar 11, 2005
26   */
27  public interface Specializer {
28  
29  	/***
30  	 * Determines whether the components in the composite can be used to create
31  	 * a specialized version of the composite that implements
32  	 * <code>specializedType</code>.
33  	 * 
34  	 * @param composite
35  	 *            the composite from which the components will be extracted
36  	 * @param specializedType
37  	 *            the type to be exposed
38  	 * @throws SpecializationException
39  	 *             if the new, specialized, composite could not be created
40  	 */
41  	public boolean isSpecializable(Object composite, Class specializedType) throws SpecializationException;
42  
43  	/***
44  	 * Uses the components in the composite to create a composite
45  	 * that implements <code>specializedType</code> and is composed only 
46  	 * those 
47  	 * 
48  	 * @param composite
49  	 *            the composite from which the components will be extracted
50  	 * @param specializedType
51  	 *            the type to be exposed
52  	 * @throws SpecializationException
53  	 *             if the new, specialized, composite could not be created
54  	 */
55  	public Object specialize(Object composite, Class specializedType) throws SpecializationException;
56  
57  }