tmf: Make TmfTimestamp and TmfTimeRange immutable
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / event / TmfTimestamp.java
index 37b74b50d2b9025d43847f40dc0c6d75e6bb175e..ca057599cbe7d516af057cb0a0d37907700835e2 100644 (file)
@@ -23,7 +23,7 @@ package org.eclipse.linuxtools.tmf.core.event;
  * @version 1.1
  * @author Francois Chouinard
  */
-public class TmfTimestamp implements ITmfTimestamp, Cloneable {
+public class TmfTimestamp implements ITmfTimestamp {
 
     // ------------------------------------------------------------------------
     // Constants
@@ -66,17 +66,17 @@ public class TmfTimestamp implements ITmfTimestamp, Cloneable {
     /**
      * The timestamp raw value (mantissa)
      */
-    private long fValue;
+    private final long fValue;
 
     /**
      * The timestamp scale (magnitude)
      */
-    private int fScale;
+    private final int fScale;
 
     /**
      * The value precision (tolerance)
      */
-    private int fPrecision;
+    private final int fPrecision;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -135,16 +135,6 @@ public class TmfTimestamp implements ITmfTimestamp, Cloneable {
         fPrecision = timestamp.getPrecision();
     }
 
-    // ------------------------------------------------------------------------
-    // Setters
-    // ------------------------------------------------------------------------
-
-    protected void setValue(long value, int scale, int precision) {
-        fValue = value;
-        fScale = scale;
-        fPrecision = precision;
-    }
-
     // ------------------------------------------------------------------------
     // ITmfTimestamp
     // ------------------------------------------------------------------------
@@ -206,7 +196,7 @@ public class TmfTimestamp implements ITmfTimestamp, Cloneable {
 
         // Handle the trivial case
         if (fScale == scale && offset == 0) {
-            return new TmfTimestamp(this);
+            return this;
         }
 
         // In case of big bang and big crunch just return this (no need to normalize)
@@ -300,26 +290,6 @@ public class TmfTimestamp implements ITmfTimestamp, Cloneable {
         return new TmfTimestamp(value, fScale, fPrecision + nts.getPrecision());
     }
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
-    /* (non-Javadoc)
-     * @see java.lang.Object#clone()
-     */
-    @Override
-    public TmfTimestamp clone() {
-        TmfTimestamp clone = null;
-        try {
-            clone = (TmfTimestamp) super.clone();
-            clone.fValue = fValue;
-            clone.fScale = fScale;
-            clone.fPrecision = fPrecision;
-        } catch (final CloneNotSupportedException e) {
-        }
-        return clone;
-    }
-
     // ------------------------------------------------------------------------
     // Comparable
     // ------------------------------------------------------------------------
This page took 0.025856 seconds and 5 git commands to generate.