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.apache.commons.lang3.Validate;
26  import org.eclipse.aether.artifact.AbstractArtifact;
27  import org.eclipse.aether.artifact.Artifact;
28  
29  /**
30   * @author Benjamin Bentmann
31   */
32  final class RelocatedArtifact
33      extends AbstractArtifact
34  {
35  
36      private final Artifact artifact;
37  
38      private final String groupId;
39  
40      private final String artifactId;
41  
42      private final String version;
43  
44      public RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version )
45      {
46          this.artifact = Validate.notNull( artifact, "artifact cannot be null" );
47          // TODO Use StringUtils here
48          this.groupId = ( groupId != null && groupId.length() > 0 ) ? groupId : null;
49          this.artifactId = ( artifactId != null && artifactId.length() > 0 ) ? artifactId : null;
50          this.version = ( version != null && version.length() > 0 ) ? version : null;
51      }
52  
53      public String getGroupId()
54      {
55          if ( groupId != null )
56          {
57              return groupId;
58          }
59          else
60          {
61              return artifact.getGroupId();
62          }
63      }
64  
65      public String getArtifactId()
66      {
67          if ( artifactId != null )
68          {
69              return artifactId;
70          }
71          else
72          {
73              return artifact.getArtifactId();
74          }
75      }
76  
77      public String getVersion()
78      {
79          if ( version != null )
80          {
81              return version;
82          }
83          else
84          {
85              return artifact.getVersion();
86          }
87      }
88  
89      public String getClassifier()
90      {
91          return artifact.getClassifier();
92      }
93  
94      public String getExtension()
95      {
96          return artifact.getExtension();
97      }
98  
99      public File getFile()
100     {
101         return artifact.getFile();
102     }
103 
104     public String getProperty( String key, String defaultValue )
105     {
106         return artifact.getProperty( key, defaultValue );
107     }
108 
109     public Map<String, String> getProperties()
110     {
111         return artifact.getProperties();
112     }
113 
114 }