View Javadoc

1   /*
2    * Copyright 2006-2008 the original author or authors.
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  
17  package org.springframework.osgi.service.importer.support;
18  
19  import java.util.List;
20  import java.util.Set;
21  import java.util.SortedSet;
22  
23  import org.springframework.core.enums.StaticLabeledEnum;
24  
25  /**
26   * Enumeration-like class which indicates the supported Spring DM managed OSGi
27   * service collection types. This class is used mainly for configuration
28   * purposes (such as parsing the OSGi namespace).
29   * 
30   * @author Costin Leau
31   */
32  public class CollectionType extends StaticLabeledEnum {
33  
34  	private static final long serialVersionUID = 6165756098619186329L;
35  
36  	/** unused */
37  	// public static final CollectionType COLLECTION = new CollectionType(1,
38  	// "collection", OsgiServiceCollection.class);
39  	/**
40  	 * Spring-managed list. The returned collection with implement the
41  	 * {@link List} interface.
42  	 * 
43  	 * @see java.util.List
44  	 */
45  	public static final CollectionType LIST = new CollectionType(2, "LIST", List.class);
46  
47  	/**
48  	 * Spring-managed set. The returned collection with implement the
49  	 * {@link Set} interface.
50  	 * 
51  	 * @see java.util.Set
52  	 */
53  	public static final CollectionType SET = new CollectionType(3, "SET", Set.class);
54  
55  	/**
56  	 * Spring-managed sorted list. The returned collection with implement the
57  	 * {@link List} interface.
58  	 * 
59  	 * @see java.lang.Comparable
60  	 * @see java.util.Comparator
61  	 * @see java.util.List
62  	 * @see java.util.SortedSet
63  	 */
64  	public static final CollectionType SORTED_LIST = new CollectionType(4, "SORTED_LIST", List.class);
65  
66  	/**
67  	 * Spring-managed sorted Set. The returned collection with implement the
68  	 * {@link SortedSet} interface.
69  	 * 
70  	 * @see java.lang.Comparable
71  	 * @see java.util.Comparator
72  	 * @see java.util.SortedSet
73  	 */
74  	public static final CollectionType SORTED_SET = new CollectionType(5, "SORTED_SET", SortedSet.class);
75  
76  	/** collection type */
77  	private final Class collectionClass;
78  
79  
80  	/**
81  	 * Returns the actual collection class used underneath.
82  	 * 
83  	 * @return collection class
84  	 */
85  	Class getCollectionClass() {
86  		return collectionClass;
87  	}
88  
89  	private CollectionType(int code, String label, Class collectionClass) {
90  		super(code, label);
91  		this.collectionClass = collectionClass;
92  	}
93  }