com.rubecula.jquantity
Interface Mutable

All Superinterfaces:
java.lang.Cloneable
All Known Subinterfaces:
Arithmutable, FuzzyMutable
All Known Implementing Classes:
Complex, Compound, FuzzInt, MutableNumber, MutablePresentation, NumberPresentation, Rational, Units

public interface Mutable
extends java.lang.Cloneable

This interface is used to define whether an object is mutable, that is to say it has non-final instance fields with mutator methods.
Note that any object which is mutable cannot properly (and safely) be copied other than by cloning (this is a fact of Java life).
Objects which are themselves immutable but which reference Cloneable objects must implement Cloneable and the clone method must clone any referenced instances which are Cloneable. This will be done via a constructor.
Objects which are mutable but do not reference any Cloneable objects must also implement Cloneable, but in this case, the clone() method will simply be of the form return (Class)super.clone().

Version:
$Revision: 1.3 $
Author:
Robin Hillyard

Method Summary
 boolean isMutable()
          This method indicates whether this particular instance is mutable, i.e. it has not been designated a constant.
 Mutable setConstant()
          This method sets this instance to be a constant, i.e. immutable.
 

Method Detail

isMutable

public boolean isMutable()
This method indicates whether this particular instance is mutable, i.e. it has not been designated a constant.

Returns:
true if this instance can be mutated, otherwise false (it is constant).

setConstant

public Mutable setConstant()
This method sets this instance to be a constant, i.e. immutable. Future calls to the isMutable() method will yield false.

Returns:
as a convenience this method returns itself.