1 /*******************************************************************************
2 * Copyright (c) 2012 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 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.util
;
17 * Pair utility class, encapsulates a pair of objects.
20 * The type of the first object.
22 * The type of the second object.
24 * @author Philippe Sawicki
27 public class Pair
<A
, B
> {
30 * A reference to the first object.
34 * A reference to the second object.
41 * The pair's first object.
43 * The pair's second object.
45 public Pair(A first
, B second
) {
61 public int hashCode() {
64 result
= prime
* result
+ ((fFirst
== null) ?
0 : fFirst
.hashCode());
65 result
= prime
* result
+ ((fSecond
== null) ?
0 : fSecond
.hashCode());
73 public boolean equals(Object obj
) {
82 if (getClass() != obj
.getClass()) {
86 Pair
<?
, ?
> other
= (Pair
<?
, ?
>) obj
;
89 if (other
.fFirst
!= null) {
92 } else if (!fFirst
.equals(other
.fFirst
)) {
95 if (fSecond
== null) {
96 if (other
.fSecond
!= null) {
99 } else if (!fSecond
.equals(other
.fSecond
)) {
109 public String
toString() {
110 return "(" + fFirst
+ ", " + fSecond
+ ")"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
114 * Returns a reference to the pair's first object.
115 * @return A reference to the pair's first object.
117 public A
getFirst() {
122 * Sets the pair's first object.
124 * The pair's first object.
126 public void setFirst(A first
) {
131 * Returns a reference to the pair's second object.
132 * @return A reference to the pair's second object.
134 public B
getSecond() {
139 * Sets the pair's second object.
141 * The pair's second object.
143 public void setSecond(B second
) {
This page took 0.034469 seconds and 5 git commands to generate.