1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
14 * @author Toni Kalajainen
16 package org.simantics.utils.datastructures;
18 import org.simantics.utils.datastructures.internal.ObjectUtils;
19 import org.simantics.utils.datastructures.map.Tuple;
22 * A generic Pair (2-tuple) structure for containing two object instances of
27 * @param <T1> type of first element
28 * @param <T2> type of second element
29 * @deprecated Replaced with {@link Tuple}
31 public final class Pair2<T1, T2> {
32 public final T1 first;
33 public final T2 second;
34 private final int hash;
36 public static <T1, T2> Pair2<T1, T2> make(T1 t1, T2 t2) {
37 return new Pair2<T1, T2>(t1, t2);
40 public Pair2(T1 first, T2 second) {
43 this.hash = makeHash();
47 public boolean equals(Object obj) {
50 if (!(obj.getClass().equals(this.getClass())))
52 Pair2<?, ?> other = (Pair2<?, ?>) obj;
53 if (!ObjectUtils.objectEquals(other.first, first))
55 if (!ObjectUtils.objectEquals(other.second, second))
61 public int hashCode() {
66 public String toString() {
67 return "<"+first+", "+second+">";
70 private int makeHash() {
73 result ^= first.hashCode();
75 result ^= second.hashCode();