View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.model.building;
20  
21  import java.io.File;
22  import java.nio.file.Path;
23  import java.util.Objects;
24  
25  import org.apache.maven.building.FileSource;
26  
27  /**
28   * Represents a model pulled from a repository
29   *
30   * @since 4.0.0
31   * @deprecated use {@link org.apache.maven.api.services.ModelBuilder} instead
32   */
33  @Deprecated(since = "4.0.0")
34  public class ArtifactModelSource extends FileSource implements ModelSource {
35      private final String groupId;
36  
37      private final String artifactId;
38  
39      private final String version;
40  
41      private final int hashCode;
42  
43      @Deprecated
44      public ArtifactModelSource(File file, String groupId, String artifactId, String version) {
45          super(file);
46          this.groupId = groupId;
47          this.artifactId = artifactId;
48          this.version = version;
49          this.hashCode = Objects.hash(groupId, artifactId, version);
50      }
51  
52      public ArtifactModelSource(Path path, String groupId, String artifactId, String version) {
53          super(path);
54          this.groupId = groupId;
55          this.artifactId = artifactId;
56          this.version = version;
57          this.hashCode = Objects.hash(groupId, artifactId, version);
58      }
59  
60      public String getGroupId() {
61          return groupId;
62      }
63  
64      public String getArtifactId() {
65          return artifactId;
66      }
67  
68      public String getVersion() {
69          return version;
70      }
71  
72      @Override
73      public int hashCode() {
74          return hashCode;
75      }
76  
77      @Override
78      public boolean equals(Object obj) {
79          if (this == obj) {
80              return true;
81          }
82          if (obj == null) {
83              return false;
84          }
85  
86          if (!ArtifactModelSource.class.equals(obj.getClass())) {
87              return false;
88          }
89  
90          ArtifactModelSource other = (ArtifactModelSource) obj;
91          return Objects.equals(artifactId, other.artifactId)
92                  && Objects.equals(groupId, other.groupId)
93                  && Objects.equals(version, other.version);
94      }
95  
96      @Override
97      public String toString() {
98          return groupId + ":" + artifactId + ":" + version;
99      }
100 }