702116251c3bf6d7d113ec2751a675694483ae8a
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / interval / TmfIntervalEndComparator.java
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
12 package org.eclipse.linuxtools.tmf.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 * @since 2.0
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 }
This page took 0.03266 seconds and 4 git commands to generate.