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