| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Reference |
|
| 2.6;2.6 |
| 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 | import org.apache.commons.lang3.builder.CompareToBuilder; | |
| 22 | ||
| 23 | /** | |
| 24 | * An external reference for a vulnerability. This contains a name, URL, and a | |
| 25 | * source. | |
| 26 | * | |
| 27 | * @author Jeremy Long | |
| 28 | */ | |
| 29 | 526 | public class Reference implements Serializable, Comparable<Reference> { |
| 30 | ||
| 31 | /** | |
| 32 | * the serial version uid. | |
| 33 | */ | |
| 34 | private static final long serialVersionUID = -3444464824563008021L; | |
| 35 | /** | |
| 36 | * The name of the reference. | |
| 37 | */ | |
| 38 | private String name; | |
| 39 | ||
| 40 | /** | |
| 41 | * Get the value of name. | |
| 42 | * | |
| 43 | * @return the value of name | |
| 44 | */ | |
| 45 | public String getName() { | |
| 46 | 0 | return name; |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * Set the value of name. | |
| 51 | * | |
| 52 | * @param name new value of name | |
| 53 | */ | |
| 54 | public void setName(String name) { | |
| 55 | 163 | this.name = name; |
| 56 | 163 | } |
| 57 | /** | |
| 58 | * the url for the reference. | |
| 59 | */ | |
| 60 | private String url; | |
| 61 | ||
| 62 | /** | |
| 63 | * Get the value of url. | |
| 64 | * | |
| 65 | * @return the value of url | |
| 66 | */ | |
| 67 | public String getUrl() { | |
| 68 | 0 | return url; |
| 69 | } | |
| 70 | ||
| 71 | /** | |
| 72 | * Set the value of url. | |
| 73 | * | |
| 74 | * @param url new value of url | |
| 75 | */ | |
| 76 | public void setUrl(String url) { | |
| 77 | 163 | this.url = url; |
| 78 | 163 | } |
| 79 | /** | |
| 80 | * the source of the reference. | |
| 81 | */ | |
| 82 | private String source; | |
| 83 | ||
| 84 | /** | |
| 85 | * Get the value of source. | |
| 86 | * | |
| 87 | * @return the value of source | |
| 88 | */ | |
| 89 | public String getSource() { | |
| 90 | 0 | return source; |
| 91 | } | |
| 92 | ||
| 93 | /** | |
| 94 | * Set the value of source. | |
| 95 | * | |
| 96 | * @param source new value of source | |
| 97 | */ | |
| 98 | public void setSource(String source) { | |
| 99 | 163 | this.source = source; |
| 100 | 163 | } |
| 101 | ||
| 102 | @Override | |
| 103 | public String toString() { | |
| 104 | 0 | return "Reference: { name='" + this.name + "', url='" + this.url + "', source='" + this.source + "' }"; |
| 105 | } | |
| 106 | ||
| 107 | @Override | |
| 108 | public boolean equals(Object obj) { | |
| 109 | 0 | if (obj == null) { |
| 110 | 0 | return false; |
| 111 | } | |
| 112 | 0 | if (getClass() != obj.getClass()) { |
| 113 | 0 | return false; |
| 114 | } | |
| 115 | 0 | final Reference other = (Reference) obj; |
| 116 | 0 | if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { |
| 117 | 0 | return false; |
| 118 | } | |
| 119 | 0 | if ((this.url == null) ? (other.url != null) : !this.url.equals(other.url)) { |
| 120 | 0 | return false; |
| 121 | } | |
| 122 | 0 | if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) { |
| 123 | 0 | return false; |
| 124 | } | |
| 125 | 0 | return true; |
| 126 | } | |
| 127 | ||
| 128 | @Override | |
| 129 | public int hashCode() { | |
| 130 | 0 | int hash = 5; |
| 131 | 0 | hash = 67 * hash + (this.name != null ? this.name.hashCode() : 0); |
| 132 | 0 | hash = 67 * hash + (this.url != null ? this.url.hashCode() : 0); |
| 133 | 0 | hash = 67 * hash + (this.source != null ? this.source.hashCode() : 0); |
| 134 | 0 | return hash; |
| 135 | } | |
| 136 | ||
| 137 | /** | |
| 138 | * Implementation of the comparable interface. | |
| 139 | * | |
| 140 | * @param o the Reference being compared | |
| 141 | * @return an integer indicating the ordering of the two objects | |
| 142 | */ | |
| 143 | @Override | |
| 144 | public int compareTo(Reference o) { | |
| 145 | 726 | return new CompareToBuilder() |
| 146 | 363 | .append(source, o.source) |
| 147 | 363 | .append(name, o.name) |
| 148 | 363 | .append(url, o.url) |
| 149 | 363 | .toComparison(); |
| 150 | } | |
| 151 | } |