Java Collection Add addAll(final Collection collection, final T... objects)

Here you can find the source of addAll(final Collection collection, final T... objects)

Description

Adds all objects into the specified list.

License

Open Source License

Parameter

Parameter Description
collection list to fill
objects objects
T objects type

Return

true if list changed as the result of this operation, false otherwise

Declaration

public static <T> boolean addAll(final Collection<T> collection, final T... objects) 

Method Source Code

//package com.java2s;
/*/*from www .  java2s . co  m*/
 * This file is part of WebLookAndFeel library.
 *
 * WebLookAndFeel library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WebLookAndFeel library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WebLookAndFeel library.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Collection;

public class Main {
    /**
     * Adds all objects into the specified list.
     *
     * @param collection
     *            list to fill
     * @param objects
     *            objects
     * @param <T>
     *            objects type
     * @return true if list changed as the result of this operation, false
     *         otherwise
     */
    public static <T> boolean addAll(final Collection<T> collection, final T... objects) {
        boolean result = false;
        for (final T object : objects) {
            if (!collection.contains(object)) {
                result |= collection.add(object);
            }
        }
        return result;
    }
}

Related

  1. addAll(final Collection c, final E... array)
  2. addAll(final Collection thingsToBeAddedTo, final Collection thingsToAdd)
  3. addAll(final Collection coll, final T... objs)
  4. addAll(final Collection collection, final T... elements)
  5. addAll(final Collection collection, final T... objects)
  6. addAll(final Collection collection, final T[] items)
  7. addAll(final T[] source, final Collection destination)
  8. addAll(final TCollection target, final Iterable source)
  9. addAll(Iterable iterable, Collection collection)