1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.shared.release.transform.jdom2;
20
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24
25 import org.apache.maven.model.Build;
26 import org.apache.maven.model.Dependency;
27 import org.apache.maven.model.DependencyManagement;
28 import org.jdom2.Element;
29
30
31
32
33
34
35
36 public class JDomModelBase {
37 private final Element modelBase;
38
39
40
41
42
43
44 public JDomModelBase(Element modelBase) {
45 this.modelBase = modelBase;
46 }
47
48
49
50
51
52
53 public Build getBuild() {
54 Element elm = modelBase.getChild("build", modelBase.getNamespace());
55 if (elm == null) {
56 return null;
57 } else {
58
59 return new JDomBuild(elm);
60 }
61 }
62
63
64
65
66
67
68 public List<Dependency> getDependencies() {
69 Element dependenciesElm = modelBase.getChild("dependencies", modelBase.getNamespace());
70 if (dependenciesElm == null) {
71 return Collections.emptyList();
72 } else {
73 List<Element> dependencyElms = dependenciesElm.getChildren("dependency", modelBase.getNamespace());
74
75 List<Dependency> dependencies = new ArrayList<>(dependencyElms.size());
76
77 for (Element dependencyElm : dependencyElms) {
78 dependencies.add(new JDomDependency(dependencyElm));
79 }
80
81 return dependencies;
82 }
83 }
84
85
86
87
88
89
90 public DependencyManagement getDependencyManagement() {
91 Element elm = modelBase.getChild("dependencyManagement", modelBase.getNamespace());
92 if (elm == null) {
93 return null;
94 } else {
95
96 return new JDomDependencyManagement(elm);
97 }
98 }
99 }