1 package org.apache.maven.repository.metadata;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.artifact.ArtifactScopeEnum;
23
24
25
26
27
28
29
30
31
32 public class MetadataGraphEdge
33 {
34 String version;
35 ArtifactScopeEnum scope;
36 int depth = -1;
37 int pomOrder = -1;
38 boolean resolved = true;
39 String artifactUri;
40
41
42
43
44
45
46
47 MetadataGraphVertex source;
48 MetadataGraphVertex target;
49
50
51 public MetadataGraphEdge( String version, boolean resolved, ArtifactScopeEnum scope, String artifactUri, int depth,
52 int pomOrder )
53 {
54 super();
55 this.version = version;
56 this.scope = scope;
57 this.artifactUri = artifactUri;
58 this.depth = depth;
59 this.resolved = resolved;
60 this.pomOrder = pomOrder;
61 }
62
63
64
65
66 private static boolean objectsEqual( Object o1, Object o2 )
67 {
68 if ( o1 == null && o2 == null )
69 {
70 return true;
71 }
72 if ( ( o1 == null && o2 != null ) || ( o1 != null && o2 == null ) )
73 {
74 return false;
75 }
76 return o1.equals( o2 );
77 }
78
79
80
81
82
83 @Override
84 public boolean equals( Object o )
85 {
86 if ( o instanceof MetadataGraphEdge )
87 {
88 MetadataGraphEdge e = (MetadataGraphEdge) o;
89
90 return objectsEqual( version, e.version )
91 && ArtifactScopeEnum.checkScope( scope ).getScope().equals( ArtifactScopeEnum.checkScope( e.scope ).getScope() )
92 && depth == e.depth;
93 }
94 return false;
95 }
96
97
98 public String getVersion()
99 {
100 return version;
101 }
102
103 public void setVersion( String version )
104 {
105 this.version = version;
106 }
107
108 public ArtifactScopeEnum getScope()
109 {
110 return scope;
111 }
112
113 public void setScope( ArtifactScopeEnum scope )
114 {
115 this.scope = scope;
116 }
117
118 public int getDepth()
119 {
120 return depth;
121 }
122
123 public void setDepth( int depth )
124 {
125 this.depth = depth;
126 }
127
128 public boolean isResolved()
129 {
130 return resolved;
131 }
132
133 public void setResolved( boolean resolved )
134 {
135 this.resolved = resolved;
136 }
137
138 public int getPomOrder()
139 {
140 return pomOrder;
141 }
142
143 public void setPomOrder( int pomOrder )
144 {
145 this.pomOrder = pomOrder;
146 }
147
148 public String getArtifactUri()
149 {
150 return artifactUri;
151 }
152
153 public void setArtifactUri( String artifactUri )
154 {
155 this.artifactUri = artifactUri;
156 }
157
158 public MetadataGraphVertex getSource()
159 {
160 return source;
161 }
162
163 public void setSource( MetadataGraphVertex source )
164 {
165 this.source = source;
166 }
167
168 public MetadataGraphVertex getTarget()
169 {
170 return target;
171 }
172
173 public void setTarget( MetadataGraphVertex target )
174 {
175 this.target = target;
176 }
177
178 @Override
179 public String toString()
180 {
181 return "[ " + "FROM:("
182 + ( source == null ? "no source" : ( source.md == null ? "no source MD" : source.md.toString() ) ) + ") "
183 + "TO:(" + ( target == null ? "no target" : ( target.md == null ? "no target MD" : target.md.toString() ) )
184 + ") " + "version=" + version + ", scope=" + ( scope == null ? "null" : scope.getScope() ) + ", depth="
185 + depth + "]";
186 }
187
188
189 }