Make the TmfLocation final and get rid of clone()
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfLocation.java
index f218d3ff538e15ec661399a89d3a86760a1db388..01da9726134c640bf15dfae5bbb3a166a187e9ba 100644 (file)
@@ -21,9 +21,9 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
  * @version 1.0
  * @author Matthew Khouzam
  */
-public class CtfLocation implements ITmfLocation<CtfLocationData>, Cloneable {
+public final class CtfLocation implements ITmfLocation {
 
-    private CtfLocationData fLocation;
+    private final CtfLocationData fLocation;
 
     /**
      * An invalid location
@@ -31,14 +31,13 @@ public class CtfLocation implements ITmfLocation<CtfLocationData>, Cloneable {
     public static final CtfLocationData INVALID_LOCATION = new CtfLocationData(-1, -1);
 
     /**
-     * Copy constructor
+     * Constructor for CtfLocation. Uses a default index of 0.
      *
-     * @param location
-     *            Other location to copy
-     * @since 2.0
+     * @param timestamp
+     *            The timestamp of this location
      */
-    public CtfLocation(CtfLocationData location) {
-        setLocation(location);
+    public CtfLocation(final ITmfTimestamp timestamp) {
+        this(timestamp.getValue(), 0);
     }
 
     /**
@@ -50,30 +49,8 @@ public class CtfLocation implements ITmfLocation<CtfLocationData>, Cloneable {
      *            The index of this location for this timestamp
      * @since 2.0
      */
-    public CtfLocation(ITmfTimestamp timestamp, long index) {
-        setLocation(new CtfLocationData(timestamp.getValue(), index));
-    }
-
-    /**
-     * Constructor for CtfLocation. Uses a default index of 0.
-     *
-     * @param timestamp
-     *            The timestamp of this location
-     */
-    @Deprecated
-    public CtfLocation(ITmfTimestamp timestamp) {
-        setLocation(new CtfLocationData(timestamp.getValue(), 0));
-    }
-
-    /**
-     * Move this location to another location's position.
-     *
-     * @param location
-     *            The location to seek to
-     * @since 2.0
-     */
-    public void setLocation(CtfLocationData location) {
-        this.fLocation = location;
+    public CtfLocation(final ITmfTimestamp timestamp, long index) {
+        this(timestamp.getValue(), index);
     }
 
     /**
@@ -85,20 +62,30 @@ public class CtfLocation implements ITmfLocation<CtfLocationData>, Cloneable {
      *            The new index
      * @since 2.0
      */
-    public void setLocation(long timestampValue, long index) {
-       this.fLocation = new CtfLocationData(timestampValue, index);
+    public CtfLocation(final long timestampValue, final long index) {
+       this(new CtfLocationData(timestampValue, index));
     }
 
+    /**
+     * Copy constructor
+     *
+     * @param location
+     *            Other location to copy
+     * @since 2.0
+     */
+    public CtfLocation(final CtfLocationData location) {
+        fLocation = location;
+    }
 
     /**
      * Get the Location Data of this location
      *
      * @return The CtfLocationData
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocation()
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationInfo()
      * @since 2.0
      */
     @Override
-    public CtfLocationData getLocation() {
+    public CtfLocationData getLocationInfo() {
         return fLocation;
     }
 
@@ -150,11 +137,10 @@ public class CtfLocation implements ITmfLocation<CtfLocationData>, Cloneable {
      */
     @Override
     public String toString() {
-        if( this.getLocation().equals(CtfLocation.INVALID_LOCATION )) {
+        if( this.getLocationInfo().equals(CtfLocation.INVALID_LOCATION )) {
             return "CtfLocation: INVALID"; //$NON-NLS-1$
         }
-        return "CtfLocation: " + getLocation().toString(); //$NON-NLS-1$
+        return "CtfLocation: " + getLocationInfo().toString(); //$NON-NLS-1$
     }
 
-
 }
This page took 0.084662 seconds and 5 git commands to generate.