import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
}
}
- // ------------------------------------------------------------------------
- // clone
- // ------------------------------------------------------------------------
-
- @Test
- public void testClone() {
- try {
- TmfCheckpoint checkpoint1 = fCheckpoint1.clone();
- TmfCheckpoint checkpoint2 = fCheckpoint1.clone();
- TmfCheckpoint checkpoint3 = fCheckpoint1.clone();
-
- assertEquals("clone", checkpoint1, fCheckpoint1);
- assertEquals("clone", checkpoint2, fCheckpoint1);
- assertEquals("clone", checkpoint3, fCheckpoint1);
-
- checkpoint1 = new TmfCheckpoint(fTimestamp1, null);
- checkpoint2 = checkpoint1.clone();
- assertEquals("clone", checkpoint1, checkpoint2);
- assertNull(checkpoint1.getContext());
- assertNull(checkpoint2.getContext());
-
- checkpoint1 = new TmfCheckpoint(null, new TmfContext(fLocation1));
- checkpoint3 = checkpoint1.clone();
- assertEquals("clone", checkpoint1, checkpoint3);
- assertNull(checkpoint1.getTimestamp());
- assertNull(checkpoint3.getTimestamp());
-
- } catch (final InternalError e) {
- fail("clone()");
- }
- }
-
// ------------------------------------------------------------------------
// compareTo
// ------------------------------------------------------------------------
*/
public ITmfLocation getLocation();
- /**
- * @return a clone of the checkpoint
- */
- public ITmfCheckpoint clone();
-
// ------------------------------------------------------------------------
// Comparable
// ------------------------------------------------------------------------
- /* (non-Javadoc)
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
@Override
public int compareTo(ITmfCheckpoint checkpoint);
* @see ITmfLocation
* @see ITmfTimestamp
*/
-public class TmfCheckpoint implements ITmfCheckpoint, Cloneable {
+public class TmfCheckpoint implements ITmfCheckpoint {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
// The checkpoint context
- private ITmfContext fContext;
+ private final ITmfContext fContext;
// The checkpoint timestamp
- private ITmfTimestamp fTimestamp;
+ private final ITmfTimestamp fTimestamp;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
- /**
- * Default constructor
- */
- @SuppressWarnings("unused")
- private TmfCheckpoint() {
- }
-
/**
* Full constructor
*
fContext = other.fContext;
}
- // ------------------------------------------------------------------------
- // Cloneable
- // ------------------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see java.lang.Object#clone()
- */
- @Override
- public TmfCheckpoint clone() {
- TmfCheckpoint clone = null;
- try {
- clone = (TmfCheckpoint) super.clone();
- clone.fContext = (fContext != null) ? fContext.clone() : null;
- clone.fTimestamp = fTimestamp;
- } catch (final CloneNotSupportedException e) {
- }
- return clone;
- }
-
// ------------------------------------------------------------------------
// ITmfCheckpoint
// ------------------------------------------------------------------------