| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Identifier |
|
| 1.875;1.875 |
| 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) 2012 Jeremy Long. All Rights Reserved. | |
| 17 | */ | |
| 18 | package org.owasp.dependencycheck.dependency; | |
| 19 | ||
| 20 | /** | |
| 21 | * | |
| 22 | * @author Jeremy Long <jeremy.long@owasp.org> | |
| 23 | */ | |
| 24 | 32 | public class Identifier implements Comparable<Identifier> { |
| 25 | ||
| 26 | /** | |
| 27 | * Constructs a new Identifier with the specified data. | |
| 28 | * | |
| 29 | * @param type the identifier type. | |
| 30 | * @param value the identifier value. | |
| 31 | * @param url the identifier url. | |
| 32 | */ | |
| 33 | public Identifier(String type, String value, String url) { | |
| 34 | this.type = type; | |
| 35 | this.value = value; | |
| 36 | this.url = url; | |
| 37 | } | |
| 38 | ||
| 39 | /** | |
| 40 | * Constructs a new Identifier with the specified data. | |
| 41 | * | |
| 42 | * @param type the identifier type. | |
| 43 | * @param value the identifier value. | |
| 44 | * @param url the identifier url. | |
| 45 | * @param description the description of the identifier. | |
| 46 | */ | |
| 47 | public Identifier(String type, String value, String url, String description) { | |
| 48 | 0 | this(type, value, url); |
| 49 | 0 | this.description = description; |
| 50 | 0 | } |
| 51 | ||
| 52 | /** | |
| 53 | * The confidence that this is the correct identifier. | |
| 54 | */ | |
| 55 | private Confidence confidence; | |
| 56 | ||
| 57 | /** | |
| 58 | * Get the value of confidence. | |
| 59 | * | |
| 60 | * @return the value of confidence | |
| 61 | */ | |
| 62 | public Confidence getConfidence() { | |
| 63 | return confidence; | |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Set the value of confidence. | |
| 68 | * | |
| 69 | * @param confidence new value of confidence | |
| 70 | */ | |
| 71 | public void setConfidence(Confidence confidence) { | |
| 72 | this.confidence = confidence; | |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * The value of the identifier | |
| 77 | */ | |
| 78 | private String value; | |
| 79 | ||
| 80 | /** | |
| 81 | * Get the value of value. | |
| 82 | * | |
| 83 | * @return the value of value | |
| 84 | */ | |
| 85 | public String getValue() { | |
| 86 | return value; | |
| 87 | } | |
| 88 | ||
| 89 | /** | |
| 90 | * Set the value of value. | |
| 91 | * | |
| 92 | * @param value new value of value | |
| 93 | */ | |
| 94 | public void setValue(String value) { | |
| 95 | this.value = value; | |
| 96 | } | |
| 97 | /** | |
| 98 | * The url for the identifier. | |
| 99 | */ | |
| 100 | private String url; | |
| 101 | ||
| 102 | /** | |
| 103 | * Get the value of url. | |
| 104 | * | |
| 105 | * @return the value of url | |
| 106 | */ | |
| 107 | public String getUrl() { | |
| 108 | return url; | |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * Set the value of url. | |
| 113 | * | |
| 114 | * @param url new value of url | |
| 115 | */ | |
| 116 | public void setUrl(String url) { | |
| 117 | this.url = url; | |
| 118 | } | |
| 119 | /** | |
| 120 | * The type of the identifier. | |
| 121 | */ | |
| 122 | private String type; | |
| 123 | ||
| 124 | /** | |
| 125 | * Get the value of type. | |
| 126 | * | |
| 127 | * @return the value of type | |
| 128 | */ | |
| 129 | public String getType() { | |
| 130 | return type; | |
| 131 | } | |
| 132 | ||
| 133 | /** | |
| 134 | * <p> | |
| 135 | * Set the value of type.</p><p> | |
| 136 | * Example would be "CPE".</p> | |
| 137 | * | |
| 138 | * @param type new value of type | |
| 139 | */ | |
| 140 | public void setType(String type) { | |
| 141 | this.type = type; | |
| 142 | } | |
| 143 | /** | |
| 144 | * A description of the identifier. | |
| 145 | */ | |
| 146 | private String description; | |
| 147 | ||
| 148 | /** | |
| 149 | * Get the value of description. | |
| 150 | * | |
| 151 | * @return the value of description | |
| 152 | */ | |
| 153 | public String getDescription() { | |
| 154 | return description; | |
| 155 | } | |
| 156 | ||
| 157 | /** | |
| 158 | * Set the value of description. | |
| 159 | * | |
| 160 | * @param description new value of description | |
| 161 | */ | |
| 162 | public void setDescription(String description) { | |
| 163 | this.description = description; | |
| 164 | } | |
| 165 | ||
| 166 | @Override | |
| 167 | public boolean equals(Object obj) { | |
| 168 | 0 | if (obj == null) { |
| 169 | 0 | return false; |
| 170 | } | |
| 171 | 0 | if (getClass() != obj.getClass()) { |
| 172 | 0 | return false; |
| 173 | } | |
| 174 | 0 | final Identifier other = (Identifier) obj; |
| 175 | 0 | if ((this.value == null) ? (other.value != null) : !this.value.equals(other.value)) { |
| 176 | 0 | return false; |
| 177 | } | |
| 178 | 0 | if ((this.type == null) ? (other.type != null) : !this.type.equals(other.type)) { |
| 179 | 0 | return false; |
| 180 | } | |
| 181 | 0 | return true; |
| 182 | } | |
| 183 | ||
| 184 | @Override | |
| 185 | public int hashCode() { | |
| 186 | 10 | int hash = 5; |
| 187 | 10 | hash = 53 * hash + (this.value != null ? this.value.hashCode() : 0); |
| 188 | 10 | hash = 53 * hash + (this.type != null ? this.type.hashCode() : 0); |
| 189 | 10 | return hash; |
| 190 | } | |
| 191 | ||
| 192 | /** | |
| 193 | * Standard implementation of toString; displays identifier value and type. | |
| 194 | * | |
| 195 | * @return a String representation of the object | |
| 196 | */ | |
| 197 | @Override | |
| 198 | public String toString() { | |
| 199 | 0 | return "Identifier{" + "value=" + value + ", type=" + type + '}'; |
| 200 | } | |
| 201 | ||
| 202 | /** | |
| 203 | * Implementation of the comparator interface. This compares the value of the identifier only. | |
| 204 | * | |
| 205 | * @param o the object being compared | |
| 206 | * @return an integer indicating the ordering | |
| 207 | */ | |
| 208 | public int compareTo(Identifier o) { | |
| 209 | 36 | if (o == null) { |
| 210 | 0 | return -1; |
| 211 | } | |
| 212 | 36 | return this.value.compareTo(o.value); |
| 213 | } | |
| 214 | } |