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