statesystem : Add a default compareTo() for segments
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / analysis / os / linux / core / latency / SystemCall.java
index 9cec0882b790a79390401a572ee036cfd9f71394..d89ff4e46dffe8c22f2a8f339c13e85272717d89 100644 (file)
@@ -9,19 +9,14 @@
 
 package org.eclipse.tracecompass.analysis.os.linux.core.latency;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
 import java.io.Serializable;
-import java.util.Comparator;
 import java.util.Map;
 
-import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
-import org.eclipse.tracecompass.segmentstore.core.SegmentComparators;
 
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Ordering;
 
 /**
  * A linux kernel system call, represented as an {@link ISegment}.
@@ -33,12 +28,6 @@ public class SystemCall implements ISegment {
 
     private static final long serialVersionUID = 1554494342105208730L;
 
-    private static final Comparator<ISegment> COMPARATOR = checkNotNull(Ordering
-            .from(SegmentComparators.INTERVAL_START_COMPARATOR)
-            .compound(SegmentComparators.INTERVAL_END_COMPARATOR)
-             /* Kind of lazy, but should work! */
-            .compound(Ordering.usingToString()));
-
     /**
      * The subset of information that is available from the syscall entry event.
      */
@@ -127,11 +116,12 @@ public class SystemCall implements ISegment {
     }
 
     @Override
-    public int compareTo(@Nullable ISegment o) {
-        if (o == null) {
-            throw new IllegalArgumentException();
+    public int compareTo(@NonNull ISegment o) {
+        int ret = ISegment.super.compareTo(o);
+        if (ret != 0) {
+            return ret;
         }
-        return COMPARATOR.compare(this, o);
+        return toString().compareTo(o.toString());
     }
 
     @Override
This page took 0.115214 seconds and 5 git commands to generate.