1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.util.artifact;
20
21 import java.io.File;
22 import java.util.Map;
23
24 import org.eclipse.aether.artifact.AbstractArtifact;
25 import org.eclipse.aether.artifact.Artifact;
26
27 import static java.util.Objects.requireNonNull;
28
29
30
31
32
33 public abstract class DelegatingArtifact extends AbstractArtifact {
34
35 private final Artifact delegate;
36
37
38
39
40
41
42 protected DelegatingArtifact(Artifact delegate) {
43 this.delegate = requireNonNull(delegate, "delegate artifact cannot be null");
44 }
45
46
47
48
49
50
51
52
53 protected abstract DelegatingArtifact newInstance(Artifact delegate);
54
55 public String getGroupId() {
56 return delegate.getGroupId();
57 }
58
59 public String getArtifactId() {
60 return delegate.getArtifactId();
61 }
62
63 public String getVersion() {
64 return delegate.getVersion();
65 }
66
67 public Artifact setVersion(String version) {
68 Artifact artifact = delegate.setVersion(version);
69 if (artifact != delegate) {
70 return newInstance(artifact);
71 }
72 return this;
73 }
74
75 public String getBaseVersion() {
76 return delegate.getBaseVersion();
77 }
78
79 public boolean isSnapshot() {
80 return delegate.isSnapshot();
81 }
82
83 public String getClassifier() {
84 return delegate.getClassifier();
85 }
86
87 public String getExtension() {
88 return delegate.getExtension();
89 }
90
91 public File getFile() {
92 return delegate.getFile();
93 }
94
95 public Artifact setFile(File file) {
96 Artifact artifact = delegate.setFile(file);
97 if (artifact != delegate) {
98 return newInstance(artifact);
99 }
100 return this;
101 }
102
103 public String getProperty(String key, String defaultValue) {
104 return delegate.getProperty(key, defaultValue);
105 }
106
107 public Map<String, String> getProperties() {
108 return delegate.getProperties();
109 }
110
111 public Artifact setProperties(Map<String, String> properties) {
112 Artifact artifact = delegate.setProperties(properties);
113 if (artifact != delegate) {
114 return newInstance(artifact);
115 }
116 return this;
117 }
118
119 @Override
120 public boolean equals(Object obj) {
121 if (obj == this) {
122 return true;
123 }
124
125 if (obj instanceof DelegatingArtifact) {
126 return delegate.equals(((DelegatingArtifact) obj).delegate);
127 }
128
129 return delegate.equals(obj);
130 }
131
132 @Override
133 public int hashCode() {
134 return delegate.hashCode();
135 }
136
137 @Override
138 public String toString() {
139 return delegate.toString();
140 }
141 }