Java Collection Convert convertCollectionType(Iterable from, C newCollection, Class listClass)

Here you can find the source of convertCollectionType(Iterable from, C newCollection, Class listClass)

Description

convert Collection Type

License

Open Source License

Declaration

public static <T, C extends Collection<T>> C convertCollectionType(Iterable<?> from, C newCollection,
            Class<T> listClass) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009-2018 Weasis Team and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v20.html
 *
 * Contributors://from   ww w .j a  va 2 s.  c o  m
 *     Nicolas Roduit - initial API and implementation
 *******************************************************************************/

import java.util.Collection;

public class Main {
    public static <T, C extends Collection<T>> C convertCollectionType(Iterable<?> from, C newCollection,
            Class<T> listClass) {
        for (Object item : from) {
            newCollection.add(listClass.cast(item));
        }
        return newCollection;
    }
}

Related

  1. convert2IntegerCollection(String[] strs)
  2. convertArrayInCollection(String[] array)
  3. convertCharCollectionToArray(Collection chars)
  4. convertCollectionInArray(Collection coll)
  5. convertCollectionStringToCSV(Collection coll, boolean valueInSingleQuotes)
  6. convertToCollection(Object source)
  7. convertToHqlParameters(Collection numbers)
  8. convertToIntArray(Collection col)
  9. convertToPrimitive(Collection info)