Coverage Report - org.owasp.dependencycheck.dependency.Identifier
 
Classes in this File Line Coverage Branch Coverage Complexity
Identifier
25%
10/39
4%
1/22
2
 
 1  
 /*
 2  
  * This file is part of dependency-check-core.
 3  
  *
 4  
  * Dependency-check-core is free software: you can redistribute it and/or modify it
 5  
  * under the terms of the GNU General Public License as published by the Free
 6  
  * Software Foundation, either version 3 of the License, or (at your option) any
 7  
  * later version.
 8  
  *
 9  
  * Dependency-check-core is distributed in the hope that it will be useful, but
 10  
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  
  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 12  
  * details.
 13  
  *
 14  
  * You should have received a copy of the GNU General Public License along with
 15  
  * dependency-check-core. If not, see http://www.gnu.org/licenses/.
 16  
  *
 17  
  * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
 18  
  */
 19  
 package org.owasp.dependencycheck.dependency;
 20  
 
 21  
 /**
 22  
  *
 23  
  * @author Jeremy Long (jeremy.long@owasp.org)
 24  
  */
 25  51
 public class Identifier implements Comparable<Identifier> {
 26  
 
 27  
     /**
 28  
      * Constructs a new Identifier with the specified data.
 29  
      *
 30  
      * @param type the identifier type.
 31  
      * @param value the identifier value.
 32  
      * @param url the identifier url.
 33  
      */
 34  110
     public Identifier(String type, String value, String url) {
 35  110
         this.type = type;
 36  110
         this.value = value;
 37  110
         this.url = url;
 38  110
     }
 39  
 
 40  
     /**
 41  
      * Constructs a new Identifier with the specified data.
 42  
      *
 43  
      * @param type the identifier type.
 44  
      * @param value the identifier value.
 45  
      * @param url the identifier url.
 46  
      * @param description the description of the identifier.
 47  
      */
 48  
     public Identifier(String type, String value, String url, String description) {
 49  0
         this(type, value, url);
 50  0
         this.description = description;
 51  0
     }
 52  
     /**
 53  
      * The value of the identifier
 54  
      */
 55  
     private String value;
 56  
 
 57  
     /**
 58  
      * Get the value of value.
 59  
      *
 60  
      * @return the value of value
 61  
      */
 62  
     public String getValue() {
 63  103
         return value;
 64  
     }
 65  
 
 66  
     /**
 67  
      * Set the value of value.
 68  
      *
 69  
      * @param value new value of value
 70  
      */
 71  
     public void setValue(String value) {
 72  0
         this.value = value;
 73  0
     }
 74  
     /**
 75  
      * The url for the identifier.
 76  
      */
 77  
     private String url;
 78  
 
 79  
     /**
 80  
      * Get the value of url.
 81  
      *
 82  
      * @return the value of url
 83  
      */
 84  
     public String getUrl() {
 85  0
         return url;
 86  
     }
 87  
 
 88  
     /**
 89  
      * Set the value of url.
 90  
      *
 91  
      * @param url new value of url
 92  
      */
 93  
     public void setUrl(String url) {
 94  0
         this.url = url;
 95  0
     }
 96  
     /**
 97  
      * The type of the identifier.
 98  
      */
 99  
     private String type;
 100  
 
 101  
     /**
 102  
      * Get the value of type.
 103  
      *
 104  
      * @return the value of type
 105  
      */
 106  
     public String getType() {
 107  26
         return type;
 108  
     }
 109  
 
 110  
     /**
 111  
      * <p>Set the value of type.</p><p>Example would be "CPE".</p>
 112  
      *
 113  
      * @param type new value of type
 114  
      */
 115  
     public void setType(String type) {
 116  0
         this.type = type;
 117  0
     }
 118  
     /**
 119  
      * A description of the identifier.
 120  
      */
 121  
     private String description;
 122  
 
 123  
     /**
 124  
      * Get the value of description.
 125  
      *
 126  
      * @return the value of description
 127  
      */
 128  
     public String getDescription() {
 129  0
         return description;
 130  
     }
 131  
 
 132  
     /**
 133  
      * Set the value of description.
 134  
      *
 135  
      * @param description new value of description
 136  
      */
 137  
     public void setDescription(String description) {
 138  0
         this.description = description;
 139  0
     }
 140  
 
 141  
     @Override
 142  
     public boolean equals(Object obj) {
 143  0
         if (obj == null) {
 144  0
             return false;
 145  
         }
 146  0
         if (getClass() != obj.getClass()) {
 147  0
             return false;
 148  
         }
 149  0
         final Identifier other = (Identifier) obj;
 150  0
         if ((this.value == null) ? (other.value != null) : !this.value.equals(other.value)) {
 151  0
             return false;
 152  
         }
 153  0
         if ((this.type == null) ? (other.type != null) : !this.type.equals(other.type)) {
 154  0
             return false;
 155  
         }
 156  0
         return true;
 157  
     }
 158  
 
 159  
     @Override
 160  
     public int hashCode() {
 161  0
         int hash = 5;
 162  0
         hash = 53 * hash + (this.value != null ? this.value.hashCode() : 0);
 163  0
         hash = 53 * hash + (this.type != null ? this.type.hashCode() : 0);
 164  0
         return hash;
 165  
     }
 166  
 
 167  
     /**
 168  
      * Standard implementation of toString; displays identifier value and type.
 169  
      *
 170  
      * @return a String representation of the object
 171  
      */
 172  
     @Override
 173  
     public String toString() {
 174  0
         return "Identifier{" + "value=" + value + ", type=" + type + '}';
 175  
     }
 176  
 
 177  
     /**
 178  
      * Implementation of the comparator interface. This compares the value of
 179  
      * the identifier only.
 180  
      *
 181  
      * @param o the object being compared
 182  
      * @return an integer indicating the ordering
 183  
      */
 184  
     public int compareTo(Identifier o) {
 185  90
         if (o == null) {
 186  0
             return -1;
 187  
         }
 188  90
         return this.value.compareTo(o.value);
 189  
     }
 190  
 }