4f7fe87d3942d6d6bfbc3ad5cb05e05614b162ae
[deliverable/tracecompass.git] / org.eclipse.tracecompass.statesystem.core / src / org / eclipse / tracecompass / statesystem / core / interval / TmfIntervalEndComparator.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 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
12 package org.eclipse.tracecompass.statesystem.core.interval;
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
22 */
23 public class TmfIntervalEndComparator implements Comparator<ITmfStateInterval> {
24
25 @Override
26 public int compare(ITmfStateInterval o1, ITmfStateInterval o2) {
27 long e1 = o1.getEndTime();
28 long e2 = o2.getEndTime();
29
30 if (e1 < e2) {
31 return -1;
32 } else if (e1 > e2) {
33 return 1;
34 } else {
35 return 0;
36 }
37 }
38
39 }
This page took 0.032195 seconds and 4 git commands to generate.