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