tmf/lttng: Remove unneeded (non-Javadoc) comments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / TmfCheckpoint.java
index 76eca5e37dff25560d7fbdd7df941844c5dfd1d8..9c93ddcaaa2345a0d012aec5d8387992d95d974c 100644 (file)
@@ -1,67 +1,62 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2012 Ericsson
- * 
+ * Copyright (c) 2009, 2013 Ericsson
+ *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
  *   Francois Chouinard - Updated as per TMF Trace Model 1.0
+ *   Patrick Tasse - Updated for location in checkpoint
  ******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.trace;
 
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 
 /**
  * A basic implementation of ITmfCheckpoint. It simply maps an event timestamp
  * to a generic location.
- * 
+ *
  * @version 1.0
  * @author Francois Chouinard
  *
  * @see ITmfLocation
  * @see ITmfTimestamp
  */
-public class TmfCheckpoint implements ITmfCheckpoint, Cloneable {
+public class TmfCheckpoint implements ITmfCheckpoint {
 
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
 
     // The checkpoint location
-    private ITmfLocation<? extends Comparable<?>> fLocation;
+    private final ITmfLocation fLocation;
 
     // The checkpoint timestamp
-    private ITmfTimestamp fTimestamp;
+    private final ITmfTimestamp fTimestamp;
 
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
-    /**
-     * Default constructor
-     */
-    @SuppressWarnings("unused")
-    private TmfCheckpoint() {
-    }
-
     /**
      * Full constructor
-     * 
+     *
      * @param timestamp the checkpoint timestamp
      * @param location the corresponding trace location
+     * @since 2.0
      */
-    public TmfCheckpoint(final ITmfTimestamp timestamp, final ITmfLocation<? extends Comparable<?>> location) {
+    public TmfCheckpoint(final ITmfTimestamp timestamp, final ITmfLocation location) {
         fTimestamp = timestamp;
         fLocation = location;
     }
 
     /**
      * Copy constructor
-     * 
+     *
      * @param other the other checkpoint
      */
     public TmfCheckpoint(final TmfCheckpoint other) {
@@ -72,42 +67,20 @@ public class TmfCheckpoint implements ITmfCheckpoint, Cloneable {
         fLocation = other.fLocation;
     }
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
-    /* (non-Javadoc)
-     * @see java.lang.Object#clone()
-     */
-    @Override
-    public TmfCheckpoint clone() {
-        TmfCheckpoint clone = null;
-        try {
-            clone = (TmfCheckpoint) super.clone();
-            clone.fLocation = (fLocation != null) ? fLocation.clone() : null;
-            clone.fTimestamp = (fTimestamp != null) ? fTimestamp.clone() : null;
-        } catch (final CloneNotSupportedException e) {
-        }
-        return clone;
-    }
-
     // ------------------------------------------------------------------------
     // ITmfCheckpoint
     // ------------------------------------------------------------------------
 
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint#getTimestamp()
+    /**
+     * @since 2.0
      */
     @Override
     public ITmfTimestamp getTimestamp() {
         return fTimestamp;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint#getLocation()
-     */
     @Override
-    public ITmfLocation<?> getLocation() {
+    public ITmfLocation getLocation() {
         return fLocation;
     }
 
@@ -115,30 +88,42 @@ public class TmfCheckpoint implements ITmfCheckpoint, Cloneable {
     // Comparable
     // ------------------------------------------------------------------------
 
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint#compareTo(org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint)
-     * 
-     * Compares the checkpoints timestamp. If either is null, compares the
-     * trace checkpoints locations.
-     */
     @Override
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public int compareTo(final ITmfCheckpoint other) {
-        if (fTimestamp == null || other.getTimestamp() == null) {
-            final Comparable location1 = fLocation.getLocation();
-            final Comparable location2 = other.getLocation().getLocation();
-            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 ((fLocation == null) && (other.getLocation() == null)) {
+            return 0;
+        }
+
+        // treat location of other as null location which is before any location
+        if ((fLocation != null) && (other.getLocation() == null)) {
+            return 1;
+        }
+
+        // treat this as null location which is before any other locations
+        if ((fLocation == null) && (other.getLocation() != 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);
     }
 
     // ------------------------------------------------------------------------
     // Object
     // ------------------------------------------------------------------------
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#hashCode()
-     */
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -148,9 +133,6 @@ public class TmfCheckpoint implements ITmfCheckpoint, Cloneable {
         return result;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
     @Override
     public boolean equals(final Object obj) {
         if (this == obj) {
@@ -180,13 +162,10 @@ public class TmfCheckpoint implements ITmfCheckpoint, Cloneable {
         return true;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
     @Override
     @SuppressWarnings("nls")
     public String toString() {
-        return "TmfCheckpoint [fLocation=" + fLocation + ", fTimestamp=" + fTimestamp + "]";
+        return getClass().getSimpleName() + " [fLocation=" + fLocation + ", fTimestamp=" + fTimestamp + "]";
     }
 
 }
This page took 0.026829 seconds and 5 git commands to generate.