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
12 package org.simantics.browsing.ui.common.internal;
\r
14 import java.util.TreeSet;
\r
17 * A wrapper Comparable class for allowing the creation of "multisets" with the
\r
18 * basic {@link TreeSet} implementation.
\r
21 * This class will define the {@link Comparable#compareTo(Object)} method in
\r
22 * such a way that the result will only be 0 if both the wrapped object and the
\r
23 * {@link #orderNumber} argument match.
\r
25 * @author Tuukka Lehtonen
\r
27 public class ComparableWrapper<T extends Comparable<T>> implements Comparable<ComparableWrapper<T>> {
\r
29 public final int orderNumber;
\r
31 public ComparableWrapper(T t, int orderNumber) {
\r
34 this.orderNumber = orderNumber;
\r
38 public int compareTo(ComparableWrapper<T> o) {
\r
39 int result = t.compareTo(o.t);
\r
40 return result != 0 ? result : (orderNumber - o.orderNumber);
\r