package com.github.blindpirate.gogradle.core;

import com.github.blindpirate.gogradle.core.dependency.GolangDependencySet;
import com.github.blindpirate.gogradle.core.dependency.parse.MapNotationParser;
import com.github.blindpirate.gogradle.core.dependency.produce.DependencyProduceStrategy;
import com.github.blindpirate.gogradle.core.dependency.resolve.DependencyFactory;
import com.google.inject.Injector;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import java.util.Collection;
import java.util.Map;
import java.util.Optional;

public class InjectionHelper {

    @SuppressWarnings({"checkstyle:staticvariablename", "checkstyle:visibilitymodifier"})
    @SuppressFBWarnings("MS_CANNOT_BE_FINAL")
    public static Injector INJECTOR_INSTANCE;

    public static GolangDependencySet parseMany(Collection<? extends Map> notations, MapNotationParser parser) {
        GolangDependencySet ret = new GolangDependencySet();
        for (Map notation : notations) {
            ret.add(parser.parse(notation));
        }
        return ret;
    }

    @SuppressFBWarnings("UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD")
    public static Optional<GolangDependencySet> produceDependencies(GolangPackageModule module) {
        return INJECTOR_INSTANCE.getInstance(DependencyFactory.class).produce(module);
    }

    public static <T extends DependencyProduceStrategy> T strategy(Class<T> clazz) {
        return INJECTOR_INSTANCE.getInstance(clazz);
    }
}

@@ -200,180 +200,8 @@
 er;%0A
-import com.github.blindpirate.gogradle.core.dependency.produce.DependencyProduceStrategy;%0Aimport com.github.blindpirate.gogradle.core.dependency.resolve.DependencyFactory;%0A
 impo
@@ -231,16 +231,16 @@
 jector;%0A
+
 import e
@@ -345,35 +345,8 @@
 Map;
-%0Aimport java.util.Optional;
 %0A%0Apu
@@ -851,24 +851,26 @@
 ret;%0A    %7D%0A%0A
+//
     @Suppres
@@ -924,16 +924,18 @@
 FIELD%22)%0A
+//
     publ
@@ -998,27 +998,34 @@
 ies(
-GolangPackageModule
+AbstractResolvedDependency
  mod
@@ -1027,24 +1027,26 @@
 y module) %7B%0A
+//
         retu
@@ -1120,23 +1120,29 @@
 odule);%0A
+//
     %7D%0A
-%0A
+//%0A//
     publ
@@ -1214,24 +1214,26 @@
 T%3E clazz) %7B%0A
+//
         retu
@@ -1273,16 +1273,18 @@
 clazz);%0A
+//
     %7D%0A%7D%0A

comment some code temporarily