FileDocCategorySizeDatePackage
MutabilityControl.javaAPI DocAndroid 1.5 API2517Wed May 06 22:41:02 BST 2009com.android.dx.util

MutabilityControl

public class MutabilityControl extends Object
Very simple base class that implements a flag to control the mutability of instances. This class just provides the flag and a utility to check and throw the right exception, but it is up to subclasses to place calls to the checker in all the right places.

Fields Summary
private boolean
mutable
whether this instance is mutable
Constructors Summary
public MutabilityControl()
Constructs an instance. It is initially mutable.

        mutable = true;
    
public MutabilityControl(boolean mutable)
Constructs an instance, explicitly indicating the mutability.

param
mutable true iff this instance is mutable

        this.mutable = mutable;
    
Methods Summary
public final booleanisImmutable()
Checks to see whether or not this instance is immutable. This is the same as calling !isMutable().

return
true iff this instance is immutable

        return !mutable;
    
public final booleanisMutable()
Checks to see whether or not this instance is mutable.

return
true iff this instance is mutable

        return mutable;
    
public voidsetImmutable()
Makes this instance immutable.

        mutable = false;
    
public final voidthrowIfImmutable()
Throws {@link MutabilityException} if this instance is immutable.

        if (!mutable) {
            throw new MutabilityException("immutable instance");
        }
    
public final voidthrowIfMutable()
Throws {@link MutabilityException} if this instance is mutable.

        if (mutable) {
            throw new MutabilityException("mutable instance");
        }