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) 2018 Paul Irwin. All Rights Reserved.
17   */
18  package org.owasp.dependencycheck.data.nuget;
19  
20  import org.apache.commons.lang3.builder.EqualsBuilder;
21  import org.apache.commons.lang3.builder.HashCodeBuilder;
22  
23  /**
24   * Represents a reference to a NuGet package and version.
25   *
26   * @author paulirwin
27   */
28  public class NugetPackageReference {
29  
30      /**
31       * The id.
32       */
33      private String id;
34  
35      /**
36       * The version.
37       */
38      private String version;
39  
40      /**
41       * Sets the id.
42       *
43       * @param id the id
44       */
45      public void setId(String id) {
46          this.id = id;
47      }
48  
49      /**
50       * Gets the id.
51       *
52       * @return the id
53       */
54      public String getId() {
55          return id;
56      }
57  
58      /**
59       * Sets the version.
60       *
61       * @param version the version
62       */
63      public void setVersion(String version) {
64          this.version = version;
65      }
66  
67      /**
68       * Gets the version.
69       *
70       * @return the version
71       */
72      public String getVersion() {
73          return version;
74      }
75  
76      /**
77       * {@inheritDoc}
78       */
79      @Override
80      public boolean equals(Object obj) {
81          if (obj == null || !(obj instanceof NugetPackageReference)) {
82              return false;
83          }
84          if (this == obj) {
85              return true;
86          }
87          final NugetPackageReference rhs = (NugetPackageReference) obj;
88          return new EqualsBuilder()
89                  .append(id, rhs.id)
90                  .append(version, rhs.version)
91                  .isEquals();
92      }
93  
94      /**
95       * {@inheritDoc}
96       */
97      @Override
98      public int hashCode() {
99          return new HashCodeBuilder(7, 89)
100                 .append(id)
101                 .append(version)
102                 .toHashCode();
103     }
104 }