1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 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
30 public class Pair
<A
, B
> {
33 * A reference to the first object.
35 private final A fFirst
;
37 * A reference to the second object.
39 private final B fSecond
;
44 * The pair's first object.
46 * The pair's second object.
48 public Pair(A first
, B second
) {
55 * Returns a reference to the pair's first object.
57 * @return A reference to the pair's first object.
64 * Returns a reference to the pair's second object.
66 * @return A reference to the pair's second object.
68 public B
getSecond() {
73 public int hashCode() {
76 result
= prime
* result
+ fFirst
.hashCode();
77 result
= prime
* result
+ fSecond
.hashCode();
82 public boolean equals(@Nullable Object obj
) {
91 if (getClass() != obj
.getClass()) {
95 Pair
<?
, ?
> other
= (Pair
<?
, ?
>) obj
;
97 if (!fFirst
.equals(other
.fFirst
)) {
100 if (!fSecond
.equals(other
.fSecond
)) {
107 public String
toString() {
108 return "(" + fFirst
+ ", " + fSecond
+ ")"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
This page took 0.052404 seconds and 6 git commands to generate.