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 bd7791c78e3d98238393dbdd2be849d5df1132b4..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
@@ -36,8 +36,8 @@ public class CtfLocation implements ITmfLocation<CtfLocationData>, Cloneable {
      * @param timestamp
      *            The timestamp of this location
      */
-    public CtfLocation(ITmfTimestamp timestamp) {
-        setLocation(new CtfLocationData(timestamp.getValue(), 0));
+    public CtfLocation(final ITmfTimestamp timestamp) {
+        this(timestamp.getValue(), 0);
     }
 
     /**
@@ -49,55 +49,43 @@ 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));
+    public CtfLocation(final ITmfTimestamp timestamp, long index) {
+        this(timestamp.getValue(), index);
     }
 
     /**
-     * Copy constructor
+     * Change this location's timestamp and index values.
      *
-     * @param location
-     *            Other location to copy
+     * @param timestampValue
+     *            The new timestamp
+     * @param index
+     *            The new index
      * @since 2.0
      */
-    public CtfLocation(CtfLocationData location) {
-        setLocation(location);
+    public CtfLocation(final long timestampValue, final long index) {
+       this(new CtfLocationData(timestampValue, index));
     }
 
     /**
-     * Move this location to another location's position.
+     * Copy constructor
      *
      * @param location
-     *            The location to seek to
-     * @since 2.0
-     */
-    public void setLocation(CtfLocationData location) {
-        this.fLocation = location;
-    }
-
-    /**
-     * Change this location's timestamp and index values.
-     *
-     * @param timestampValue
-     *            The new timestamp
-     * @param index
-     *            The new index
+     *            Other location to copy
      * @since 2.0
      */
-    public void setLocation(long timestampValue, long index) {
-       this.fLocation = new CtfLocationData(timestampValue, index);
+    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;
     }
 
@@ -149,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.02601 seconds and 5 git commands to generate.