| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Pair |
|
| 2.75;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 | 25656 | public Pair(L left, R right) { |
| 43 | 25656 | this.left = left; |
| 44 | 25656 | this.right = right; |
| 45 | 25656 | } |
| 46 | /** | |
| 47 | * The left element of the pair. | |
| 48 | */ | |
| 49 | 25656 | 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 | 25656 | 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 | 25656 | 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 | 25656 | 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 | 25656 | int hash = 3; |
| 99 | 25656 | hash = 53 * hash + (this.left != null ? this.left.hashCode() : 0); |
| 100 | 25656 | hash = 53 * hash + (this.right != null ? this.right.hashCode() : 0); |
| 101 | 25656 | 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 | } |