1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.segmentstore
.core
;
12 import java
.util
.Comparator
;
14 import org
.eclipse
.jdt
.annotation
.Nullable
;
17 * Segments comparators. These do not allow for null arguments.
19 * @author Alexandre Montplaisir
20 * @noimplement This interface only contains static definitions.
22 public interface SegmentComparators
{
25 * Basic long comparator
27 Comparator
<Long
> LONG_COMPARATOR
= new Comparator
<Long
>() {
29 public int compare(@Nullable Long o1
, @Nullable Long o2
) {
30 if (o1
== null || o2
== null) {
31 throw new IllegalArgumentException();
33 return o1
.compareTo(o2
);
38 * Start time comparator
40 Comparator
<ISegment
> INTERVAL_START_COMPARATOR
= new Comparator
<ISegment
>() {
42 public int compare(@Nullable ISegment o1
, @Nullable ISegment o2
) {
43 if (o1
== null || o2
== null) {
44 throw new IllegalArgumentException();
46 return Long
.compare(o1
.getStart(), o2
.getStart());
53 Comparator
<ISegment
> INTERVAL_END_COMPARATOR
= new Comparator
<ISegment
>() {
55 public int compare(@Nullable ISegment o1
, @Nullable ISegment o2
) {
56 if (o1
== null || o2
== null) {
57 throw new IllegalArgumentException();
59 return Long
.compare(o1
.getEnd(), o2
.getEnd());
66 Comparator
<ISegment
> INTERVAL_LENGTH_COMPARATOR
= new Comparator
<ISegment
>() {
68 public int compare(@Nullable ISegment o1
, @Nullable ISegment o2
) {
69 if (o1
== null || o2
== null) {
70 throw new IllegalArgumentException();
72 return Long
.compare(o1
.getLength(), o2
.getLength());