001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.collections.primitives.adapters;
018
019import java.util.Collection;
020import java.util.Iterator;
021import java.util.List;
022import java.util.ListIterator;
023
024import org.apache.commons.collections.primitives.ByteCollection;
025import org.apache.commons.collections.primitives.ByteIterator;
026import org.apache.commons.collections.primitives.ByteList;
027import org.apache.commons.collections.primitives.ByteListIterator;
028import org.apache.commons.collections.primitives.CharCollection;
029import org.apache.commons.collections.primitives.CharIterator;
030import org.apache.commons.collections.primitives.CharList;
031import org.apache.commons.collections.primitives.CharListIterator;
032import org.apache.commons.collections.primitives.DoubleCollection;
033import org.apache.commons.collections.primitives.DoubleIterator;
034import org.apache.commons.collections.primitives.DoubleList;
035import org.apache.commons.collections.primitives.DoubleListIterator;
036import org.apache.commons.collections.primitives.FloatCollection;
037import org.apache.commons.collections.primitives.FloatIterator;
038import org.apache.commons.collections.primitives.FloatList;
039import org.apache.commons.collections.primitives.FloatListIterator;
040import org.apache.commons.collections.primitives.IntCollection;
041import org.apache.commons.collections.primitives.IntIterator;
042import org.apache.commons.collections.primitives.IntList;
043import org.apache.commons.collections.primitives.IntListIterator;
044import org.apache.commons.collections.primitives.LongCollection;
045import org.apache.commons.collections.primitives.LongIterator;
046import org.apache.commons.collections.primitives.LongList;
047import org.apache.commons.collections.primitives.LongListIterator;
048import org.apache.commons.collections.primitives.ShortCollection;
049import org.apache.commons.collections.primitives.ShortIterator;
050import org.apache.commons.collections.primitives.ShortList;
051import org.apache.commons.collections.primitives.ShortListIterator;
052
053/**
054 * Convenience methods for constructing adapters.
055 *  
056 * @since Commons Primitives 1.1
057 * @version $Revision: 480462 $ $Date: 2006-11-29 03:15:00 -0500 (Wed, 29 Nov 2006) $
058 * @author Rodney Waldhoff 
059 */
060public final class Adapt {
061    public Adapt() {
062    }
063    
064    // to object based
065    //---------------------------------------------------------------
066
067    public static final Collection toCollection(ByteCollection c) {
068        return ByteCollectionCollection.wrap(c);
069    }
070    
071    public static final Collection toCollection(CharCollection c) {
072        return CharCollectionCollection.wrap(c);
073    }
074    
075    public static final Collection toCollection(DoubleCollection c) {
076        return DoubleCollectionCollection.wrap(c);
077    }
078    
079    public static final Collection toCollection(FloatCollection c) {
080        return FloatCollectionCollection.wrap(c);
081    }
082    
083    public static final Collection toCollection(IntCollection c) {
084        return IntCollectionCollection.wrap(c);
085    }
086    
087    public static final Collection toCollection(LongCollection c) {
088        return LongCollectionCollection.wrap(c);
089    }
090    
091    public static final Collection toCollection(ShortCollection c) {
092        return ShortCollectionCollection.wrap(c);
093    }
094
095    public static final List toList(ByteList c) {
096        return ByteListList.wrap(c);
097    }
098    
099    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}