/*
 * Copyright 2015 Michael Rozumyanskiy
 *
 * 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 io.michaelrocks.lightsaber;

import javax.inject.Provider;
import java.lang.annotation.Annotation;

public class Lightsaber {
    public static Injector createInjector(final Object... modules) {
        throw new IllegalStateException(
                "This method must not be called. Seems the project hasn't been processed with Lightsaber");
    }

    public static <T> T getInstance(final Injector injector, final Class<? extends T> type) {
        return injector.getInstance(Key.of(type));
    }

    public static <T> T getInstance(final Injector injector, final Class<? extends T> type,
            final Annotation annotation) {
        return injector.getInstance(Key.of(type, annotation));
    }

    public static <T> Provider<T> getProvider(final Injector injector, final Class<? extends T> type) {
        return injector.getProvider(Key.of(type));
    }

    public static <T> Provider<T> getProvider(final Injector injector, final Class<? extends T> type,
            final Annotation annotation) {
        return injector.getProvider(Key.of(type, annotation));
    }
}

@@ -704,16 +704,38 @@
 otation;
+%0Aimport java.util.Map;
 %0A%0Apublic
@@ -754,16 +754,811 @@
 saber %7B%0A
+    private static final Configurator DEFAULT_CONFIGURATOR = new DefaultConfigurator();%0A%0A    private static volatile Lightsaber instance;%0A    private static final Object instanceLock = new Object();%0A%0A    private final Map%3CClass%3C?%3E, MembersInjector%3C?%3E%3E membersInjectors;%0A    private final Object%5B%5D packageModules;%0A%0A    Lightsaber(final Configurator configurator) %7B%0A        membersInjectors = configurator.getMembersInjectors();%0A        packageModules = configurator.getPackageModules();%0A    %7D%0A%0A    public static Lightsaber getInstance() %7B%0A        if (instance == null) %7B%0A            synchronized (instanceLock) %7B%0A                if (instance == null) %7B%0A                    instance = new Lightsaber(DEFAULT_CONFIGURATOR);%0A                %7D%0A            %7D%0A        %7D%0A        return instance;%0A    %7D%0A%0A
     publ
@@ -2430,32 +2430,32 @@
 n annotation) %7B%0A
-
         return i
@@ -2506,11 +2506,562 @@
 );%0A    %7D
+%0A%0A    interface Configurator %7B%0A        Map%3CClass%3C?%3E, MembersInjector%3C?%3E%3E getMembersInjectors();%0A        Object%5B%5D getPackageModules();%0A    %7D%0A%0A    private static class DefaultConfigurator implements Configurator %7B%0A        @Override%0A        public Map%3CClass%3C?%3E, MembersInjector%3C?%3E%3E getMembersInjectors() %7B%0A            // noinspection unchecked%0A            return LightsaberRegistry.getMembersInjectors();%0A        %7D%0A%0A        @Override%0A        public Object%5B%5D getPackageModules() %7B%0A            return LightsaberRegistry.getPackageModules();%0A        %7D%0A    %7D
 %0A%7D%0A

Make Lightsaber a singleton