View Javadoc

1   /*
2    * Copyright (c) 2007 Creative Sphere Limited.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *
10   *   Creative Sphere - initial API and implementation
11   *
12   */
13  package org.abstracthorizon.extend.repository.maven.pom;
14  
15  import java.util.ArrayList;
16  import java.util.List;
17  
18  public class Exclusions {
19  
20      protected List<Exclusion> exclusions = new ArrayList<Exclusion>();
21      
22      public Exclusions() {
23      }
24  
25      public List<Exclusion> getExclusions() {
26          return exclusions;
27      }
28      
29      public Exclusion addExclusion() {
30          Exclusion exclusion = new Exclusion();
31          exclusions.add(exclusion);
32          return exclusion;
33      }
34       
35      public boolean contains(Artifact dependency) {
36          for (Exclusion e : getExclusions()) {
37              if (dependency.getGroupId().equals(e.getGroupId()) && dependency.getArtifactId().equals(e.getArtifactId())) {
38                  // TODO is this enough?
39                  return true;
40              }
41          }
42          return false;
43      }
44      
45      public String toString(int indent) {
46          StringBuffer res = new StringBuffer();
47          ToStringHelper.openTag("exclusions", res, indent);
48          for (Exclusion exclusion : exclusions) {
49              res.append(exclusion.toString(indent + 2));
50          }
51          ToStringHelper.closeTag("exclusions", res, indent);
52          return res.toString();
53      }
54  
55      public String toString() {
56          return toString(2);
57      }
58  
59  }