Java List Join join(List... lists)

Here you can find the source of join(List... lists)

Description

join

License

Open Source License

Declaration

public static <T> List<T> join(List<T>... lists) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;
import java.util.Collection;

import java.util.List;
import java.util.Map;

public class Main {
    public static <T> List<T> join(List<T>... lists) {
        List<T> result = new ArrayList<T>();
        for (List<T> list : lists) {
            result.addAll(list);/*from   w w  w .  j  a  v a2s  . c  o  m*/
        }
        return result;
    }

    public static <T> void addAll(Collection<T> col, T[] arr) {
        if (isEmpty(arr)) {
            return;
        }
        for (T val : arr) {
            col.add(val);
        }
    }

    public static <T> boolean isEmpty(T[] vals) {
        return vals == null || vals.length == 0;
    }

    public static <T> boolean isEmpty(T[] vals, boolean checkNullVal) {
        boolean isEmpty = vals == null || vals.length == 0;
        if (isEmpty) {
            return true;
        }
        if (checkNullVal) {
            for (T val : vals) {
                if (val != null) {
                    return false;
                }
            }
            isEmpty = true;
        }
        return isEmpty;
    }

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

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

Related

  1. join(List objects, String separator)
  2. join(List objs, String delim)
  3. join(List target, String splite)
  4. join(List tokens, String delimiter)
  5. join(List values, String separator)
  6. join(List... ls)
  7. join(List... elements)
  8. join(String _delimiter, List _strings)
  9. join(String delimiter, List strings)