View Javadoc

1   /*
2    *  Licensed under the Apache License, Version 2.0 (the "License");
3    *  you may not use this file except in compliance with the License.
4    *  You may obtain a copy of the License at
5    *
6    *      http://www.apache.org/licenses/LICENSE-2.0
7    *
8    *  Unless required by applicable law or agreed to in writing, software
9    *  distributed under the License is distributed on an "AS IS" BASIS,
10   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   *  See the License for the specific language governing permissions and
12   *  limitations under the License.
13   */
14  /*
15   * This file has been modified by Chris Pheby in accordance with Section 4.2
16   * of the Apache Software License
17   */
18  package org.jadira.dependencynavigator.model;
19  
20  import java.util.ArrayList;
21  import java.util.List;
22  
23  public class ExclusionList {
24      private List<String> exclusions;
25  
26      public void addExclusion(String groupId, String artifactId) {
27          if (exclusions == null) {
28              // lazy load the list as most artifacts will have no exclusions
29              exclusions = new ArrayList<String>();
30          }
31          String exclusion = groupId + ":" + artifactId;
32          if (!exclusions.contains(exclusion)) {
33              exclusions.add(exclusion);
34          }
35      }
36  
37      public boolean isExcluded(String groupId, String artifactId) {
38          String identifier = groupId + ":" + artifactId;
39          if (exclusions != null) {
40              for (String exclusion : exclusions) {
41                  if (exclusion.equalsIgnoreCase(identifier)) {
42                      return true;
43                  }
44              }
45          }
46          return false;
47      }
48  }