c805ece46e26e00b0648cb2cd68e71c427df6fc0
1 /*******************************************************************************
2 * Copyright (c) 2012, 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Philippe Sawicki (INF4990.A2010@gmail.com) - Initial API and implementation
11 * Mathieu Denis (mathieu.denis55@gmail.com) - Refactored code
12 * Bernd Hufmann - Integrated to TMF, fixed hashCode() and equals() methods
13 * Alexandre Montplaisir - Made non-null and immutable
14 *******************************************************************************/
15 package org
.eclipse
.tracecompass
.tmf
.core
.util
;
17 import org
.eclipse
.jdt
.annotation
.Nullable
;
20 * Pair utility class, encapsulates a pair of objects.
23 * The type of the first object.
25 * The type of the second object.
27 * @author Philippe Sawicki
29 public class Pair
<A
, B
> {
32 * A reference to the first object.
34 private final A fFirst
;
36 * A reference to the second object.
38 private final B fSecond
;
43 * The pair's first object.
45 * The pair's second object.
47 public Pair(A first
, B second
) {
54 * Returns a reference to the pair's first object.
56 * @return A reference to the pair's first object.
63 * Returns a reference to the pair's second object.
65 * @return A reference to the pair's second object.
67 public B
getSecond() {
72 public int hashCode() {
75 result
= prime
* result
+ fFirst
.hashCode();
76 result
= prime
* result
+ fSecond
.hashCode();
81 public boolean equals(@Nullable Object obj
) {
90 if (getClass() != obj
.getClass()) {
94 Pair
<?
, ?
> other
= (Pair
<?
, ?
>) obj
;
96 if (!fFirst
.equals(other
.fFirst
)) {
99 if (!fSecond
.equals(other
.fSecond
)) {
106 public String
toString() {
107 return "(" + fFirst
+ ", " + fSecond
+ ")"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
This page took 0.04481 seconds and 4 git commands to generate.