Java Collection Combine combineCollections(Collection sessionCollection, Collection reqCollection)

Here you can find the source of combineCollections(Collection sessionCollection, Collection reqCollection)

Description

combine Collections

License

Open Source License

Declaration

public static <T> Collection<T> combineCollections(Collection<T> sessionCollection,
            Collection<T> reqCollection) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *******************************************************************************/

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

public class Main {
    public static <T> Collection<T> combineCollections(Collection<T> sessionCollection,
            Collection<T> reqCollection) {
        Collection<T> result = null;

        if (sessionCollection != null && !sessionCollection.isEmpty()) {
            result = new ArrayList<T>();
            result.addAll(sessionCollection);
        }/* w  w w .  j a  va 2s.c  om*/

        if (reqCollection != null && !reqCollection.isEmpty()) {
            if (result == null) {
                result = new ArrayList<T>();
            }
            result.addAll(reqCollection);
        }

        return result;
    }
}

Related

  1. combine(final Collection[] c)
  2. combine(String separator, Collection parts)
  3. combine(String separator, Collection stringCollection)
  4. combine(String separator, Collection objs)
  5. combineAndRemoveDuplicates(Collection collection1, Collection collection2)
  6. CombineCollections(final Collection... collections)
  7. combineNames(Collection items)
  8. combineProblemMessages(final Collection problems)
  9. combineString(Collection vec, String sep)

  10. HOME | Copyright © www.java2s.com 2016