View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.collections.primitives.adapters;
18  
19  import java.util.Collection;
20  import java.util.Iterator;
21  import java.util.List;
22  import java.util.ListIterator;
23  
24  import org.apache.commons.collections.primitives.ByteCollection;
25  import org.apache.commons.collections.primitives.ByteIterator;
26  import org.apache.commons.collections.primitives.ByteList;
27  import org.apache.commons.collections.primitives.ByteListIterator;
28  import org.apache.commons.collections.primitives.CharCollection;
29  import org.apache.commons.collections.primitives.CharIterator;
30  import org.apache.commons.collections.primitives.CharList;
31  import org.apache.commons.collections.primitives.CharListIterator;
32  import org.apache.commons.collections.primitives.DoubleCollection;
33  import org.apache.commons.collections.primitives.DoubleIterator;
34  import org.apache.commons.collections.primitives.DoubleList;
35  import org.apache.commons.collections.primitives.DoubleListIterator;
36  import org.apache.commons.collections.primitives.FloatCollection;
37  import org.apache.commons.collections.primitives.FloatIterator;
38  import org.apache.commons.collections.primitives.FloatList;
39  import org.apache.commons.collections.primitives.FloatListIterator;
40  import org.apache.commons.collections.primitives.IntCollection;
41  import org.apache.commons.collections.primitives.IntIterator;
42  import org.apache.commons.collections.primitives.IntList;
43  import org.apache.commons.collections.primitives.IntListIterator;
44  import org.apache.commons.collections.primitives.LongCollection;
45  import org.apache.commons.collections.primitives.LongIterator;
46  import org.apache.commons.collections.primitives.LongList;
47  import org.apache.commons.collections.primitives.LongListIterator;
48  import org.apache.commons.collections.primitives.ShortCollection;
49  import org.apache.commons.collections.primitives.ShortIterator;
50  import org.apache.commons.collections.primitives.ShortList;
51  import org.apache.commons.collections.primitives.ShortListIterator;
52  
53  /**
54   * Convenience methods for constructing adapters.
55   *  
56   * @since Commons Primitives 1.1
57   * @version $Revision: 480462 $ $Date: 2006-11-29 03:15:00 -0500 (Wed, 29 Nov 2006) $
58   * @author Rodney Waldhoff 
59   */
60  public final class Adapt {
61      public Adapt() {
62      }
63      
64      // to object based
65      //---------------------------------------------------------------
66  
67      public static final Collection toCollection(ByteCollection c) {
68          return ByteCollectionCollection.wrap(c);
69      }
70      
71      public static final Collection toCollection(CharCollection c) {
72          return CharCollectionCollection.wrap(c);
73      }
74      
75      public static final Collection toCollection(DoubleCollection c) {
76          return DoubleCollectionCollection.wrap(c);
77      }
78      
79      public static final Collection toCollection(FloatCollection c) {
80          return FloatCollectionCollection.wrap(c);
81      }
82      
83      public static final Collection toCollection(IntCollection c) {
84          return IntCollectionCollection.wrap(c);
85      }
86      
87      public static final Collection toCollection(LongCollection c) {
88          return LongCollectionCollection.wrap(c);
89      }
90      
91      public static final Collection toCollection(ShortCollection c) {
92          return ShortCollectionCollection.wrap(c);
93      }
94  
95      public static final List toList(ByteList c) {
96          return ByteListList.wrap(c);
97      }
98      
99      public static final List toList(CharList c) {
100         return CharListList.wrap(c);
101     }
102     
103     public static final List toList(DoubleList c) {
104         return DoubleListList.wrap(c);
105     }
106     
107     public static final List toList(FloatList c) {
108         return FloatListList.wrap(c);
109     }
110     
111     public static final List toList(IntList c) {
112         return IntListList.wrap(c);
113     }
114     
115     public static final List toList(LongList c) {
116         return LongListList.wrap(c);
117     }
118     
119     public static final List toList(ShortList c) {
120         return ShortListList.wrap(c);
121     }
122 
123     public static final Iterator toIterator(ByteIterator c) {
124         return ByteIteratorIterator.wrap(c);
125     }
126     
127     public static final Iterator toIterator(CharIterator c) {
128         return CharIteratorIterator.wrap(c);
129     }
130     
131     public static final Iterator toIterator(DoubleIterator c) {
132         return DoubleIteratorIterator.wrap(c);
133     }
134     
135     public static final Iterator toIterator(FloatIterator c) {
136         return FloatIteratorIterator.wrap(c);
137     }
138     
139     public static final Iterator toIterator(IntIterator c) {
140         return IntIteratorIterator.wrap(c);
141     }
142     
143     public static final Iterator toIterator(LongIterator c) {
144         return LongIteratorIterator.wrap(c);
145     }
146     
147     public static final Iterator toIterator(ShortIterator c) {
148         return ShortIteratorIterator.wrap(c);
149     }
150 
151     public static final ListIterator toListIterator(ByteListIterator c) {
152         return ByteListIteratorListIterator.wrap(c);
153     }
154     
155     public static final ListIterator toListIterator(CharListIterator c) {
156         return CharListIteratorListIterator.wrap(c);
157     }
158     
159     public static final ListIterator toListIterator(DoubleListIterator c) {
160         return DoubleListIteratorListIterator.wrap(c);
161     }
162     
163     public static final ListIterator toListIterator(FloatListIterator c) {
164         return FloatListIteratorListIterator.wrap(c);
165     }
166     
167     public static final ListIterator toListIterator(IntListIterator c) {
168         return IntListIteratorListIterator.wrap(c);
169     }
170     
171     public static final ListIterator toListIterator(LongListIterator c) {
172         return LongListIteratorListIterator.wrap(c);
173     }
174     
175     public static final ListIterator toListIterator(ShortListIterator c) {
176         return ShortListIteratorListIterator.wrap(c);
177     }
178 
179     // to byte based
180     //---------------------------------------------------------------
181     
182     public static final ByteCollection toByteCollection(Collection c) {
183         return CollectionByteCollection.wrap(c);
184     }
185 
186     public static final ByteList toByteList(List c) {
187         return ListByteList.wrap(c);
188     }
189 
190     public static final ByteIterator toByteIterator(Iterator c) {
191         return IteratorByteIterator.wrap(c);
192     }
193 
194     public static final ByteListIterator toByteListIterator(ListIterator c) {
195         return ListIteratorByteListIterator.wrap(c);
196     }
197 
198     // to char based
199     //---------------------------------------------------------------
200     
201     public static final CharCollection toCharCollection(Collection c) {
202         return CollectionCharCollection.wrap(c);
203     }
204 
205     public static final CharList toCharList(List c) {
206         return ListCharList.wrap(c);
207     }
208 
209     public static final CharIterator toCharIterator(Iterator c) {
210         return IteratorCharIterator.wrap(c);
211     }
212 
213     public static final CharListIterator toCharListIterator(ListIterator c) {
214         return ListIteratorCharListIterator.wrap(c);
215     }
216 
217     // to double based
218     //---------------------------------------------------------------
219     
220     public static final DoubleCollection toDoubleCollection(Collection c) {
221         return CollectionDoubleCollection.wrap(c);
222     }
223 
224     public static final DoubleList toDoubleList(List c) {
225         return ListDoubleList.wrap(c);
226     }
227 
228     public static final DoubleIterator toDoubleIterator(Iterator c) {
229         return IteratorDoubleIterator.wrap(c);
230     }
231 
232     public static final DoubleListIterator toDoubleListIterator(ListIterator c) {
233         return ListIteratorDoubleListIterator.wrap(c);
234     }
235     
236     // to float based
237     //---------------------------------------------------------------
238     
239     public static final FloatCollection toFloatCollection(Collection c) {
240         return CollectionFloatCollection.wrap(c);
241     }
242 
243     public static final FloatList toFloatList(List c) {
244         return ListFloatList.wrap(c);
245     }
246 
247     public static final FloatIterator toFloatIterator(Iterator c) {
248         return IteratorFloatIterator.wrap(c);
249     }
250 
251     public static final FloatListIterator toFloatListIterator(ListIterator c) {
252         return ListIteratorFloatListIterator.wrap(c);
253     }
254     
255     // to int based
256     //---------------------------------------------------------------
257     
258     public static final IntCollection toIntCollection(Collection c) {
259         return CollectionIntCollection.wrap(c);
260     }
261 
262     public static final IntList toIntList(List c) {
263         return ListIntList.wrap(c);
264     }
265 
266     public static final IntIterator toIntIterator(Iterator c) {
267         return IteratorIntIterator.wrap(c);
268     }
269 
270     public static final IntListIterator toIntListIterator(ListIterator c) {
271         return ListIteratorIntListIterator.wrap(c);
272     }
273     
274     // to long based
275     //---------------------------------------------------------------
276     
277     public static final LongCollection toLongCollection(Collection c) {
278         return CollectionLongCollection.wrap(c);
279     }
280 
281     public static final LongList toLongList(List c) {
282         return ListLongList.wrap(c);
283     }
284 
285     public static final LongIterator toLongIterator(Iterator c) {
286         return IteratorLongIterator.wrap(c);
287     }
288 
289     public static final LongListIterator toLongListIterator(ListIterator c) {
290         return ListIteratorLongListIterator.wrap(c);
291     }
292     
293     // to short based
294     //---------------------------------------------------------------
295     
296     public static final ShortCollection toShortCollection(Collection c) {
297         return CollectionShortCollection.wrap(c);
298     }
299 
300     public static final ShortList toShortList(List c) {
301         return ListShortList.wrap(c);
302     }
303 
304     public static final ShortIterator toShortIterator(Iterator c) {
305         return IteratorShortIterator.wrap(c);
306     }
307 
308     public static final ShortListIterator toShortListIterator(ListIterator c) {
309         return ListIteratorShortListIterator.wrap(c);
310     }
311 }