View Javadoc
1   package org.apache.maven.repository.internal;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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   * @author Benjamin Bentmann
30   */
31  final class RelocatedArtifact
32      extends AbstractArtifact
33  {
34  
35      private final Artifact artifact;
36  
37      private final String groupId;
38  
39      private final String artifactId;
40  
41      private final String version;
42  
43      public RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version )
44      {
45          if ( artifact == null )
46          {
47              throw new IllegalArgumentException( "no artifact specified" );
48          }
49          this.artifact = artifact;
50          this.groupId = ( groupId != null && groupId.length() > 0 ) ? groupId : null;
51          this.artifactId = ( artifactId != null && artifactId.length() > 0 ) ? artifactId : null;
52          this.version = ( version != null && version.length() > 0 ) ? version : null;
53      }
54  
55      public String getGroupId()
56      {
57          if ( groupId != null )
58          {
59              return groupId;
60          }
61          else
62          {
63              return artifact.getGroupId();
64          }
65      }
66  
67      public String getArtifactId()
68      {
69          if ( artifactId != null )
70          {
71              return artifactId;
72          }
73          else
74          {
75              return artifact.getArtifactId();
76          }
77      }
78  
79      public String getVersion()
80      {
81          if ( version != null )
82          {
83              return version;
84          }
85          else
86          {
87              return artifact.getVersion();
88          }
89      }
90  
91      public String getClassifier()
92      {
93          return artifact.getClassifier();
94      }
95  
96      public String getExtension()
97      {
98          return artifact.getExtension();
99      }
100 
101     public File getFile()
102     {
103         return artifact.getFile();
104     }
105 
106     public String getProperty( String key, String defaultValue )
107     {
108         return artifact.getProperty( key, defaultValue );
109     }
110 
111     public Map<String, String> getProperties()
112     {
113         return artifact.getProperties();
114     }
115 
116 }