Java List Copy copyTypes(List src, List dest)

Here you can find the source of copyTypes(List src, List dest)

Description

copy Types

License

Open Source License

Declaration

public static List<String> copyTypes(List<String> src, List<String> dest) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public class Main {

    public static List<String> copyTypes(List<String> src, List<String> dest) {
        if (isEmpty(src)) {
            if (dest != null) {
                dest.clear();// w  w  w  .ja  v a2  s.  co  m
            }
        } else {
            if (dest == null) {
                dest = new ArrayList<String>(src.size());
            } else {
                dest.clear();
            }
            dest.addAll(src);
        }
        return dest;
    }

    public static boolean isEmpty(Collection<?> coll) {
        return coll == null || coll.isEmpty();
    }

    public static boolean isEmpty(Map<?, ?> map) {
        return map == null || map.isEmpty();
    }
}

Related

  1. copyStringList(List l1)
  2. copyStringList(List list)
  3. copyToArray(List list, float[] array)
  4. copyToArrayListWithExtraCapacity(T[] elements, int extraCapacity)
  5. copyToList(Iterable elements)