/*
 * Copyright (c) 2013-2015 Cinchapi, Inc.
 *
 * 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.cinchapi.concourse.util;

import java.util.List;

import com.google.common.base.Preconditions;

/**
 * Utilities for Lists.
 * 
 * @author Jeff Nelson
 */
public final class TLists {

    /**
     * Modify each list to retain only the elements that are contained in all of
     * the lists.
     * 
     * @param lists
     */
    @SafeVarargs
    public static void retainIntersection(List<?>... lists) {
        Preconditions.checkArgument(lists.length > 0);
        List<?> intersection = lists[0];
        for (int i = 1; i < lists.length; ++i) {
            intersection.retainAll(lists[i]);
        }
        for (int i = 1; i < lists.length; ++i) {
            lists[i].retainAll(intersection);
        }
    }

    private TLists() {/* noop */}

}

@@ -40,16 +40,17 @@
  Inc.%0A *
+ 
 %0A * Lice
@@ -226,13 +226,12 @@
 t%0A *
+ 
 %0A *
-  
  htt
@@ -272,16 +272,17 @@
 E-2.0%0A *
+ 
 %0A * Unle
@@ -1330,16 +1330,413 @@
 %0A    %7D%0A%0A
+    /**%0A     * Syntactic sugar for transforming a generic %7B@link List%7D into an array%0A     * with the same generic type. This method performs the casting so that the%0A     * calling code doesn't have to.%0A     * %0A     * @param list%0A     * @return the array%0A     */%0A    @SuppressWarnings(%22unchecked%22)%0A    public static %3CT%3E T%5B%5D toArrayCasted(List%3CT%3E list) %7B%0A        return (T%5B%5D) list.toArray();%0A    %7D%0A%0A
     priv

add a method to convert a list to an array using casting