/*
 * Copyright 2010-2011 Ning, Inc.
 *
 * Ning licenses this file to you 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 com.ning.metrics.collector.binder.providers;

import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Provider;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;

public class ArrayListProvider<T> implements Provider<List<T>>
{
    private Injector injector;
    private final List<Key<? extends T>> injectables = new ArrayList<Key<? extends T>>();

    @Inject
    public void configure(final Injector injector)
    {
        this.injector = injector;
    }

    public ArrayListProvider<T> add(final Class<? extends T> toBeIncluded)
    {
        injectables.add(Key.get(toBeIncluded));
        return this;
    }

    public ArrayListProvider<T> add(final Class<? extends Annotation> annotation, final Class<? extends T> toBeIncluded)
    {
        injectables.add(Key.get(toBeIncluded, annotation));
        return this;
    }

    public ArrayListProvider<T> add(final Annotation annotation, final Class<? extends T> toBeIncluded)
    {
        injectables.add(Key.get(toBeIncluded, annotation));
        return this;
    }

    @Override
    public List<T> get()
    {
        final List<T> retVal = new ArrayList<T>();
        for (final Key<? extends T> injectable : injectables) {
            retVal.add(injector.getInstance(injectable));
        }
        return retVal;
    }
}

@@ -873,16 +873,45 @@
 ayList;%0A
+import java.util.Collection;%0A
 import j
@@ -1040,20 +1040,26 @@
 e final 
-List
+Collection
 %3CKey%3C? e
@@ -1233,380 +1233,8 @@
  %7D%0A%0A
-    public ArrayListProvider%3CT%3E add(final Class%3C? extends T%3E toBeIncluded)%0A    %7B%0A        injectables.add(Key.get(toBeIncluded));%0A        return this;%0A    %7D%0A%0A    public ArrayListProvider%3CT%3E add(final Class%3C? extends Annotation%3E annotation, final Class%3C? extends T%3E toBeIncluded)%0A    %7B%0A        injectables.add(Key.get(toBeIncluded, annotation));%0A        return this;%0A    %7D%0A%0A
     

remove unused code in ArrayListProvider