Support for multiple events for same timestamp at checkpoint
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / TmfCheckpoint.java
index a2135ec572add3cd2d52cd42da347f9df8031f1c..ee58f0081ec74685e8cd33bf5e72cec41b614b95 100644 (file)
@@ -132,12 +132,33 @@ public class TmfCheckpoint implements ITmfCheckpoint, Cloneable {
     @Override
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public int compareTo(final ITmfCheckpoint other) {
-        if (fTimestamp == null || other.getTimestamp() == null) {
-            final Comparable location1 = getLocation().getLocationInfo();
-            final Comparable location2 = other.getLocation().getLocationInfo();
-            return location1.compareTo(location2);
+        int comp = 0;
+        if ((fTimestamp != null) && (other.getTimestamp() != null)) {
+            comp = fTimestamp.compareTo(other.getTimestamp(), false);
+            if (comp != 0) {
+                return comp;
+            }
+            // compare locations if timestamps are the same
+        }
+
+        if ((getContext() == null) && (other.getContext() == null)) {
+            return 0;
+        }
+
+        // treat location of other as null location which is before any location
+        if ((getContext() != null) && (other.getContext() == null)) {
+            return 1;
+        }
+
+        // treat this as null location which is before any other locations
+        if ((getContext() == null) && (other.getContext() != null)) {
+            return -1;
         }
-        return fTimestamp.compareTo(other.getTimestamp(), false);
+
+        // compare location
+        final Comparable location1 = getLocation().getLocationInfo();
+        final Comparable location2 = other.getLocation().getLocationInfo();
+        return location1.compareTo(location2);
     }
 
     // ------------------------------------------------------------------------
This page took 0.02403 seconds and 5 git commands to generate.