View Javadoc

1   /*
2    *  Copyright 2003-2004 The Apache Software Foundation
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  package net.sf.collections15.list;
17  
18  import java.util.List;
19  
20  
21  /***
22   * After the port to JDK5.0, this class should be deprecated in a future release.
23   *   
24   * Decorates another <code>List</code> to validate that elements
25   * added are of a specific type.
26   * <p>
27   * The validation of additions is performed via an instanceof test against 
28   * a specified <code>Class</code>. If an object cannot be added to the
29   * collection, an IllegalArgumentException is thrown.
30   *
31   * @deprecated Useless after port to JDK5.0
32   * @since Commons Collections 3.0
33   * @version $Revision: 1.1 $ $Date: 2005/05/03 22:45:38 $
34   * 
35   * @author Stephen Colebourne
36   * @author Matthew Hawthorne
37   */
38  public class TypedList {
39  
40      /***
41       * Factory method to create a typed list.
42       * <p>
43       * If there are any elements already in the list being decorated, they
44       * are validated.
45       * 
46       * @param list  the list to decorate, must not be null
47       * @param type  the type to allow into the collection, must not be null
48       * @throws IllegalArgumentException if list or type is null
49       * @throws IllegalArgumentException if the list contains invalid elements
50       */
51      public static <T> List<T> decorate(List<T> list, Class type) {
52  		return list;
53  //        return new PredicatedList(list, InstanceofPredicate.getInstance(type));
54      }
55      
56      /***
57       * Restrictive constructor.
58       */
59      protected TypedList() {
60      }
61  
62  }