Java List Merge mergerList(List sources, List targets)

Here you can find the source of mergerList(List sources, List targets)

Description

merger List

License

Open Source License

Declaration

public static <T> List<T> mergerList(List<T> sources, List<T> targets) 

Method Source Code


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

import java.util.ArrayList;
import java.util.Collection;

import java.util.List;

public class Main {

    public static <T> List<T> mergerList(List<T> sources, List<T> targets) {
        List<T> results = new ArrayList<T>();
        if (sources != null && !sources.isEmpty()) {
            results.addAll(sources);/*from w  w w.j a v  a 2s  .  co  m*/
        }
        if (targets != null && !targets.isEmpty()) {
            results.addAll(targets);
        }
        return results;
    }

    public static <T> List<T> mergerList(List<List<T>> sources) {
        List<T> results = new ArrayList<T>();
        if (sources == null || sources.isEmpty()) {
            return results;
        }
        for (List<T> source : sources) {
            if (source == null || source.isEmpty()) {
                continue;
            }
            results.addAll(source);
        }
        return results;
    }

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

Related

  1. mergeLists(List listA, List listB, List listC)
  2. mergeLists(Object oldValue, Object newValue, Object newValue2)
  3. mergeOperations(List> list1, Set ops2)
  4. mergeOrdered( List base, List elems)
  5. mergepath(List pieces, String separator)
  6. mergeSpeakerList(List speaker_list)
  7. mergeString(List strs)
  8. mergeTimeStrings(List strs)
  9. mergeTo(List target, List source)

    HOME | Copyright © www.java2s.com 2016