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