Coverage Report - org.owasp.dependencycheck.utils.Pair
 
Classes in this File Line Coverage Branch Coverage Complexity
Pair
42%
12/28
10%
2/20
2.75
 
 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) 2014 Jeremy Long. All Rights Reserved.
 17  
  */
 18  
 package org.owasp.dependencycheck.utils;
 19  
 
 20  
 /**
 21  
  * A generic pair of elements.
 22  
  *
 23  
  * @param <L> the type for the left element in the pair
 24  
  * @param <R> the type for the right element in the pair
 25  
  *
 26  
  * @author Jeremy Long
 27  
  */
 28  
 public class Pair<L, R> {
 29  
 
 30  
     /**
 31  
      * Constructs a new empty pair.
 32  
      */
 33  0
     public Pair() {
 34  0
     }
 35  
 
 36  
     /**
 37  
      * Constructs a new Pair with the given left and right values.
 38  
      *
 39  
      * @param left the value for the left pair
 40  
      * @param right the value for the right pair
 41  
      */
 42  25470
     public Pair(L left, R right) {
 43  25470
         this.left = left;
 44  25470
         this.right = right;
 45  25470
     }
 46  
     /**
 47  
      * The left element of the pair.
 48  
      */
 49  25470
     private L left = null;
 50  
 
 51  
     /**
 52  
      * Get the value of left.
 53  
      *
 54  
      * @return the value of left
 55  
      */
 56  
     public L getLeft() {
 57  25470
         return left;
 58  
     }
 59  
 
 60  
     /**
 61  
      * Set the value of left.
 62  
      *
 63  
      * @param left new value of left
 64  
      */
 65  
     public void setLeft(L left) {
 66  0
         this.left = left;
 67  0
     }
 68  
     /**
 69  
      * The right element of the pair.
 70  
      */
 71  25470
     private R right = null;
 72  
 
 73  
     /**
 74  
      * Get the value of right.
 75  
      *
 76  
      * @return the value of right
 77  
      */
 78  
     public R getRight() {
 79  25470
         return right;
 80  
     }
 81  
 
 82  
     /**
 83  
      * Set the value of right.
 84  
      *
 85  
      * @param right new value of right
 86  
      */
 87  
     public void setRight(R right) {
 88  0
         this.right = right;
 89  0
     }
 90  
 
 91  
     /**
 92  
      * Generates the hash code using the hash codes from the contained objects.
 93  
      *
 94  
      * @return the hash code of the Pair
 95  
      */
 96  
     @Override
 97  
     public int hashCode() {
 98  25482
         int hash = 3;
 99  25482
         hash = 53 * hash + (this.left != null ? this.left.hashCode() : 0);
 100  25482
         hash = 53 * hash + (this.right != null ? this.right.hashCode() : 0);
 101  25482
         return hash;
 102  
     }
 103  
 
 104  
     /**
 105  
      * Determines the equality of this and the provided object.
 106  
      *
 107  
      * @param obj the {@link Object} to check for equality to this
 108  
      * @return true if this and the provided {@link Object} are equal; otherwise false
 109  
      */
 110  
     @Override
 111  
     public boolean equals(Object obj) {
 112  0
         if (obj == null) {
 113  0
             return false;
 114  
         }
 115  0
         if (getClass() != obj.getClass()) {
 116  0
             return false;
 117  
         }
 118  0
         final Pair<?, ?> other = (Pair<?, ?>) obj;
 119  0
         if (this.left != other.left && (this.left == null || !this.left.equals(other.left))) {
 120  0
             return false;
 121  
         }
 122  0
         if (this.right != other.right && (this.right == null || !this.right.equals(other.right))) {
 123  0
             return false;
 124  
         }
 125  0
         return true;
 126  
     }
 127  
 }