Commit | Line | Data |
---|---|---|
61759503 AM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 Ericsson | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * Alexandre Montplaisir - Initial API and implementation | |
10 | *******************************************************************************/ | |
11 | ||
bcec0116 | 12 | package org.eclipse.linuxtools.statesystem.core.interval; |
f9a76cac AM |
13 | |
14 | import java.util.Comparator; | |
15 | ||
16 | /** | |
17 | * Comparator for ITmfStateInterval, using their *end times*. Making intervals | |
18 | * Comparable wouldn't be clear if it's using their start or end times (or maybe | |
19 | * even values), so separate comparators are provided. | |
20 | * | |
21 | * @author Alexandre Montplaisir | |
bcec0116 | 22 | * @since 3.0 |
f9a76cac AM |
23 | */ |
24 | public class TmfIntervalEndComparator implements Comparator<ITmfStateInterval> { | |
25 | ||
26 | @Override | |
27 | public int compare(ITmfStateInterval o1, ITmfStateInterval o2) { | |
28 | long e1 = o1.getEndTime(); | |
29 | long e2 = o2.getEndTime(); | |
30 | ||
31 | if (e1 < e2) { | |
32 | return -1; | |
33 | } else if (e1 > e2) { | |
34 | return 1; | |
35 | } else { | |
36 | return 0; | |
37 | } | |
38 | } | |
39 | ||
40 | } |