package checkdep.common;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import jdepend.framework.JavaPackage;
import checkdep.value.depend.Dependencies;
import checkdep.value.depend.Dependency;
import checkdep.value.depend.PackageName;

public class JDependDependency implements Dependency {
  private final JavaPackage raw;

  public JDependDependency(JavaPackage raw) {
    this.raw = raw;
  }

  @Override
  public PackageName getName() {
    return new PackageName(raw.getName());
  }

  @Override
  public Set<PackageName> getEfferents() {
    Set<PackageName> res = new LinkedHashSet<PackageName>();
    @SuppressWarnings("unchecked")
    Collection<JavaPackage> efferents = raw.getEfferents();
    for (JavaPackage efferent : efferents) {
      res.add(new PackageName(efferent.getName()));
    }
    return res;
  }

  public static Dependencies toDependencies(Collection<JavaPackage> packages) {
    List<Dependency> res = new ArrayList<Dependency>();
    for (JavaPackage item : packages) {
      res.add(new JDependDependency(item));
    }
    return Dependencies.of(res);
  }
}

@@ -23,36 +23,8 @@
 n;%0A%0A
-import java.util.ArrayList;%0A
 impo
@@ -84,31 +84,8 @@
 et;%0A
-import java.util.List;%0A
 impo
@@ -940,19 +940,18 @@
 ) %7B%0A    
-Lis
+Se
 t%3CDepend
@@ -970,16 +970,20 @@
 new 
-ArrayLis
+LinkedHashSe
 t%3CDe

modify Set <- List