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