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.morph.reflect.reflectors;
17  
18  import java.util.HashSet;
19  import java.util.Set;
20  
21  import net.sf.morph.reflect.GrowableContainerReflector;
22  import net.sf.morph.reflect.InstantiatingReflector;
23  
24  /**
25   * Exposes the information found in a {@link java.util.Set}.
26   * 
27   * @author Matt Sgarlata
28   * @since Nov 26, 2004
29   */
30  public class SetReflector
31  	extends CollectionReflector
32  	implements GrowableContainerReflector, InstantiatingReflector {
33  
34  	private static final Class[] REFLECTABLE_TYPES = new Class[] { Set.class };
35  
36  	protected Object newInstanceImpl(Class interfaceClass, Object parameters) throws Exception {
37  		return interfaceClass == Set.class ? new HashSet() : super.newInstanceImpl(interfaceClass, parameters);
38  	}
39  
40  	public Class[] getReflectableClassesImpl() {
41  		return REFLECTABLE_TYPES;
42  	}
43  
44  }