Java List Merge mergeLists(List copyTo, List copyFrom)

Here you can find the source of mergeLists(List copyTo, List copyFrom)

Description

merge Lists

License

Open Source License

Declaration

public static <T> List<T> mergeLists(List<T> copyTo,
            List<T> copyFrom) 

Method Source Code

//package com.java2s;
/*/*w ww .ja va  2s.co  m*/
 * Copyright (c) 2016 VMware, Inc. All Rights Reserved.
 *
 * This product is licensed to you under the Apache License, Version 2.0 (the "License").
 * You may not use this product except in compliance with the License.
 *
 * This product may include a number of subcomponents with separate copyright notices
 * and license terms. Your use of these subcomponents is subject to the terms and
 * conditions of the subcomponent's license, as noted in the LICENSE file.
 */

import java.util.List;

public class Main {
    public static <T> List<T> mergeLists(List<T> copyTo, List<T> copyFrom) {
        if (copyTo == null) {
            return copyFrom;
        } else if (copyFrom != null && !copyFrom.isEmpty()) {
            for (T t : copyTo) {
                if (!copyFrom.contains(t)) {
                    copyFrom.add(t);
                }
            }

            return copyFrom;
        }

        return copyTo;
    }
}

Related

  1. mergeList(List list1, List list2)
  2. mergeList(List list, List... others)
  3. mergeListNoDuplicate(List one, List two)
  4. mergeLists(final T... array)
  5. mergeLists(List baseList, List newItems)
  6. mergeLists(List dest, List inserts)
  7. mergeLists(List listA, List listB, List listC)
  8. mergeLists(Object oldValue, Object newValue, Object newValue2)
  9. mergeOperations(List> list1, Set ops2)