1 /*******************************************************************************
2 * Copyright (c) 2011 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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.lttng
.core
.util
;
16 * Pair utility class, encapsulates a pair of objects.
18 * @author Philippe Sawicki
21 * The type of the first object.
23 * The type of the second object.
25 public abstract class Pair
<A
, B
> {
28 * A reference to the first object.
32 * A reference to the second object.
39 * The pair's first object.
41 * The pair's second object.
43 public Pair(A first
, B second
) {
59 public int hashCode() {
60 int hashFirst
= fFirst
!= null ? fFirst
.hashCode() : 0;
61 int hashSecond
= fSecond
!= null ? fSecond
.hashCode() : 0;
63 return (hashFirst
+ hashSecond
) * hashSecond
+ hashFirst
;
70 @SuppressWarnings("unchecked")
71 public boolean equals(Object other
) {
72 if (other
instanceof Pair
) {
73 Pair
<A
, B
> otherPair
= (Pair
<A
, B
>) other
;
74 return ((fFirst
== otherPair
.fFirst
|| (fFirst
!= null && otherPair
.fFirst
!= null && fFirst
.equals(otherPair
.fFirst
))) && (fSecond
== otherPair
.fSecond
|| (fSecond
!= null
75 && otherPair
.fSecond
!= null && fSecond
.equals(otherPair
.fSecond
))));
84 public String
toString() {
85 return "(" + fFirst
+ ", " + fSecond
+ ")"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
89 * Returns a reference to the pair's first object.
90 * @return A reference to the pair's first object.
97 * Sets the pair's first object.
99 * The pair's first object.
101 public void setFirst(A first
) {
106 * Returns a reference to the pair's second object.
107 * @return A reference to the pair's second object.
109 public B
getSecond() {
114 * Sets the pair's second object.
116 * The pair's second object.
118 public void setSecond(B second
) {
This page took 0.034083 seconds and 5 git commands to generate.