package org.eclipse.tracecompass.segmentstore.core;
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
-import java.util.Comparator;
-
-import org.eclipse.jdt.annotation.Nullable;
-
-import com.google.common.collect.Ordering;
-
/**
* Basic implementation of {@link ISegment}.
*
private static final long serialVersionUID = -3257452887960883177L;
- private static final Comparator<ISegment> COMPARATOR;
- static {
- /* checkNotNull() has to be called separately, or else it breaks the
- * type inference. */
- Comparator<ISegment> comp = Ordering
- .from(SegmentComparators.INTERVAL_START_COMPARATOR)
- .compound(SegmentComparators.INTERVAL_END_COMPARATOR);
- COMPARATOR = checkNotNull(comp);
- }
-
private final long fStart;
private final long fEnd;
return fEnd;
}
- @Override
- public int compareTo(@Nullable ISegment o) {
- if (o == null) {
- throw new IllegalArgumentException();
- }
- return COMPARATOR.compare(this, o);
- }
-
@Override
public String toString() {
return new String('[' + String.valueOf(fStart) + ", " + String.valueOf(fEnd) + ']'); //$NON-NLS-1$