View Javadoc
1   /*
2    * This file is part of dependency-check-core.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   * Copyright (c) 2015 The OWASP Foundation. All Rights Reserved.
17   */
18  package org.owasp.dependencycheck.data.composer;
19  
20  /**
21   * Reperesents a dependency (GAV, right now) from a Composer dependency.
22   *
23   * @author colezlaw
24   */
25  public final class ComposerDependency {
26  
27      /**
28       * The group
29       */
30      private final String group;
31  
32      /**
33       * The project
34       */
35      private final String project;
36  
37      /**
38       * The version
39       */
40      private final String version;
41  
42      /**
43       * Create a ComposerDependency from group, project, and version.
44       *
45       * @param group the group
46       * @param project the project
47       * @param version the version
48       */
49      public ComposerDependency(String group, String project, String version) {
50          this.group = group;
51          this.project = project;
52          this.version = version;
53      }
54  
55      /**
56       * Get the group.
57       *
58       * @return the group
59       */
60      public String getGroup() {
61          return group;
62      }
63  
64      /**
65       * Get the project.
66       *
67       * @return the project
68       */
69      public String getProject() {
70          return project;
71      }
72  
73      /**
74       * Get the version.
75       *
76       * @return the version
77       */
78      public String getVersion() {
79          return version;
80      }
81  
82      @Override
83      public boolean equals(Object o) {
84          if (this == o) {
85              return true;
86          }
87          if (!(o instanceof ComposerDependency)) {
88              return false;
89          }
90  
91          final ComposerDependency that = (ComposerDependency) o;
92  
93          if (group != null ? !group.equals(that.group) : that.group != null) {
94              return false;
95          }
96          if (project != null ? !project.equals(that.project) : that.project != null) {
97              return false;
98          }
99          return !(version != null ? !version.equals(that.version) : that.version != null);
100 
101     }
102 
103     @Override
104     public int hashCode() {
105         int result = group != null ? group.hashCode() : 0;
106         result = 31 * result + (project != null ? project.hashCode() : 0);
107         result = 31 * result + (version != null ? version.hashCode() : 0);
108         return result;
109     }
110 }