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 Dependencies {
19  
20      protected List<Dependency> dependencies = new ArrayList<Dependency>();
21      
22      public Dependencies() {
23      }
24      
25      public List<Dependency> getDependencies() {
26          return dependencies;
27      }
28      
29      public Dependency addDependency() {
30          Dependency dependency = new Dependency();
31          dependencies.add(dependency);
32          return dependency;
33      }
34      
35      public Dependency findDependency(String groupId, String artifactId) {
36          for (Dependency dependency : dependencies) {
37              if (groupId.equals(dependency.getGroupId()) && artifactId.equals(dependency.getArtifactId())) {
38                  return dependency;
39              }
40          }
41          return null;
42      }
43      
44      public String toString(int indent) {
45          StringBuffer res = new StringBuffer();
46          ToStringHelper.openTag("dependencies", res, indent);
47          for (Dependency dep : dependencies) {
48              res.append(dep.toString(indent + 2));
49          }
50          ToStringHelper.closeTag("dependencies", res, indent);
51          return res.toString();
52      }
53  
54      public String toString() {
55          return toString(2);
56      }
57  
58  }