All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.qas.api.internal.util.google.collect.Iterables Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2007 The Guava Authors
 *
 * 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
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.qas.api.internal.util.google.collect;

import java.util.Collection;

import static org.qas.api.internal.util.google.base.Preconditions.checkNotNull;

/**
 * This class contains static utility methods that operate on or return objects
 * of type {@code Iterable}. Except as noted, each method has a corresponding
 * Iterator-based method in the {@link Iterators} class.
 *
 * 

Performance notes: Unless otherwise noted, all of the iterables * produced in this class are lazy, which means that their iterators * only advance the backing iteration when absolutely necessary. * *

See the Guava User Guide article on * {@code Iterables}. * * @author Kevin Bourrillion * @author Jared Levy * @author Dzung Nguyen * @version $Id Iterables 2014-03-27 09:11:30z dungvnguyen $ * @since 1.0 */ public class Iterables { /** * Adds all elements in {@code iterable} to {@code collection}. * * @return {@code true} if {@code collection} was modified as a result of this * operation. */ public static boolean addAll( Collection addTo, Iterable elementsToAdd) { if (elementsToAdd instanceof Collection) { Collection c = Collections2.cast(elementsToAdd); return addTo.addAll(c); } return Iterators.addAll(addTo, checkNotNull(elementsToAdd).iterator()); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy