ss: Bug 475300: Fix inconsistent TreeMapStore due to value comparators
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.segmentstore.core / src / org / eclipse / tracecompass / segmentstore / core / SegmentComparators.java
1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9
10 package org.eclipse.tracecompass.segmentstore.core;
11
12 import java.util.Comparator;
13
14 import org.eclipse.jdt.annotation.Nullable;
15
16 /**
17 * Segments comparators. These do not allow for null arguments.
18 *
19 * @author Alexandre Montplaisir
20 * @noimplement This interface only contains static definitions.
21 */
22 public interface SegmentComparators {
23
24 /**
25 * Basic long comparator
26 */
27 Comparator<Long> LONG_COMPARATOR = new Comparator<Long>() {
28 @Override
29 public int compare(@Nullable Long o1, @Nullable Long o2) {
30 if (o1 == null || o2 == null) {
31 throw new IllegalArgumentException();
32 }
33 return o1.compareTo(o2);
34 }
35 };
36
37 /**
38 * Start time comparator
39 */
40 Comparator<ISegment> INTERVAL_START_COMPARATOR = new Comparator<ISegment>() {
41 @Override
42 public int compare(@Nullable ISegment o1, @Nullable ISegment o2) {
43 if (o1 == null || o2 == null) {
44 throw new IllegalArgumentException();
45 }
46 return Long.compare(o1.getStart(), o2.getStart());
47 }
48 };
49
50 /**
51 * End time comparator
52 */
53 Comparator<ISegment> INTERVAL_END_COMPARATOR = new Comparator<ISegment>() {
54 @Override
55 public int compare(@Nullable ISegment o1, @Nullable ISegment o2) {
56 if (o1 == null || o2 == null) {
57 throw new IllegalArgumentException();
58 }
59 return Long.compare(o1.getEnd(), o2.getEnd());
60 }
61 };
62
63 /**
64 * Length comparator
65 */
66 Comparator<ISegment> INTERVAL_LENGTH_COMPARATOR = new Comparator<ISegment>() {
67 @Override
68 public int compare(@Nullable ISegment o1, @Nullable ISegment o2) {
69 if (o1 == null || o2 == null) {
70 throw new IllegalArgumentException();
71 }
72 return Long.compare(o1.getLength(), o2.getLength());
73 }
74 };
75
76 }
This page took 0.042599 seconds and 5 git commands to generate.