1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.repository.metadata;
20
21 import org.apache.maven.artifact.Artifact;
22 import org.apache.maven.artifact.ArtifactScopeEnum;
23
24
25
26
27
28
29 @Deprecated
30 public class MetadataTreeNode {
31 ArtifactMetadata md;
32
33 MetadataTreeNode parent;
34
35
36 int nChildren = 8;
37
38 MetadataTreeNode[] children;
39
40 public int getNChildren() {
41 return nChildren;
42 }
43
44 public void setNChildren(int children) {
45 nChildren = children;
46 }
47
48
49 public MetadataTreeNode() {}
50
51 public MetadataTreeNode(ArtifactMetadata md, MetadataTreeNode parent, boolean resolved, ArtifactScopeEnum scope) {
52 if (md != null) {
53 md.setArtifactScope(ArtifactScopeEnum.checkScope(scope));
54 md.setResolved(resolved);
55 }
56
57 this.md = md;
58 this.parent = parent;
59 }
60
61 public MetadataTreeNode(Artifact af, MetadataTreeNode parent, boolean resolved, ArtifactScopeEnum scope) {
62 this(new ArtifactMetadata(af), parent, resolved, scope);
63 }
64
65
66 public void addChild(int index, MetadataTreeNode kid) {
67 if (kid == null) {
68 return;
69 }
70
71 if (children == null) {
72 children = new MetadataTreeNode[nChildren];
73 }
74
75 children[index % nChildren] = kid;
76 }
77
78
79 @Override
80 public String toString() {
81 return md == null ? "no metadata" : md.toString();
82 }
83
84
85 public String graphHash() throws MetadataResolutionException {
86 if (md == null) {
87 throw new MetadataResolutionException(
88 "treenode without metadata, parent: " + (parent == null ? "null" : parent.toString()));
89 }
90
91 return md.groupId + ":" + md.artifactId;
92 }
93
94
95 public boolean hasChildren() {
96 return children != null;
97 }
98
99 public ArtifactMetadata getMd() {
100 return md;
101 }
102
103 public void setMd(ArtifactMetadata md) {
104 this.md = md;
105 }
106
107 public MetadataTreeNode getParent() {
108 return parent;
109 }
110
111 public void setParent(MetadataTreeNode parent) {
112 this.parent = parent;
113 }
114
115 public MetadataTreeNode[] getChildren() {
116 return children;
117 }
118
119 public void setChildren(MetadataTreeNode[] children) {
120 this.children = children;
121 }
122
123
124
125 }