/*-
 * Copyright (c) 2012-2013 Red Hat, 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.fedoraproject.maven;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

import org.fedoraproject.maven.model.Artifact;

public class ArtifactBlacklist
{
    private static final Map<String, Set<String>> blacklist = new TreeMap<>();

    public static boolean contains( String groupId, String artifactId )
    {
        Set<String> group = blacklist.get( groupId );
        return group != null && group.contains( artifactId );
    }

    public static boolean contains( Artifact artifact )
    {
        return contains( artifact.getGroupId(), artifact.getArtifactId() );
    }

    public static void add( String groupId, String artifactId )
    {
        Set<String> group = blacklist.get( groupId );

        if ( group == null )
        {
            group = new TreeSet<>();
            blacklist.put( groupId, group );
        }

        group.add( artifactId );
    }

    public static void add( Artifact artifact )
    {
        add( artifact.getGroupId(), artifact.getArtifactId() );
    }

    static
    {
        add( Artifact.DUMMY );
        add( Artifact.DUMMY_JPP );

        // TODO: This list should be configurable somehow
        add( "javax.activation", "activation" );
        add( "org.eclipse.jetty.orbit", "javax.activation" );
        add( "org.apache.maven.wagon", "wagon-webdav" );
        add( "org.apache.maven.wagon", "wagon-webdav-jackrabbit" );
    }
}

@@ -655,59 +655,11 @@
 til.
-Map;%0Aimport java.util.Set;%0Aimport java.util.TreeMap
+Set
 ;%0Aim
@@ -793,31 +793,20 @@
 nal 
-Map%3CString, Set%3CString%3E
+Set%3CArtifact
 %3E bl
@@ -827,11 +827,11 @@
 Tree
-Map
+Set
 %3C%3E()
@@ -923,101 +923,47 @@
     
-Set%3CString%3E group = blacklist.get( groupId );%0A        return group != null && group.contains(
+return contains( new Artifact( groupId,
  art
@@ -961,32 +961,34 @@
 upId, artifactId
+ )
  );%0A    %7D%0A%0A    p
@@ -1051,32 +1051,42 @@
 %0A        return 
+blacklist.
 contains( artifa
@@ -1092,44 +1092,32 @@
 act.
-getGroupId(), artifact.getArtifactId
+clearVersionAndExtension
 () )
@@ -1207,205 +1207,35 @@
     
-Set%3CString%3E group = blacklist.get( groupId );%0A%0A        if ( group == null )%0A        %7B%0A            group = new TreeSet%3C%3E();%0A            blacklist.put( groupId, group );%0A        %7D%0A%0A        group.add(
+add( new Artifact( groupId,
  art
@@ -1241,16 +1241,18 @@
 tifactId
+ )
  );%0A    
@@ -1312,24 +1312,34 @@
   %7B%0A        
+blacklist.
 add( artifac
@@ -1344,44 +1344,32 @@
 act.
-getGroupId(), artifact.getArtifactId
+clearVersionAndExtension
 () )

Reimplement ArtifactBlacklist using java.util.Set