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 *******************************************************************************/
12 package org.simantics.diagram.content;
15 * @author Tuukka Lehtonen
17 * @param <T> a comparable type
19 public class OrderedPair<T extends Comparable<T>> {
21 private final T first;
22 private final T second;
24 public OrderedPair(T first, T second) {
26 assert second != null;
28 int comp = first.compareTo(second);
47 public int hashCode() {
48 return (first.hashCode() * 31) + second.hashCode();
52 public boolean equals(Object obj) {
55 if (!(obj instanceof OrderedPair<?>))
57 OrderedPair<?> other = (OrderedPair<?>) obj;
58 return first.equals(other.first) && second.equals(other.second);
61 public static <T extends Comparable<T>> OrderedPair<T> make(T ra, T rb) {
62 return new OrderedPair<T>(ra, rb);