Class MutabilityControl

java.lang.Object
com.android.dx.util.MutabilityControl
Direct Known Subclasses:
Annotation, Annotations, ExecutionStack, FixedSizeList, IntList, LocalsArray, LocalVariableInfo, LocalVariableInfo, RegisterSpecSet, StdConstantPool, SwitchList

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.
  • Constructor Details

    • MutabilityControl

      public MutabilityControl()
      Constructs an instance. It is initially mutable.
    • MutabilityControl

      public MutabilityControl(boolean mutable)
      Constructs an instance, explicitly indicating the mutability.
      Parameters:
      mutable - true iff this instance is mutable
  • Method Details

    • setImmutable

      public void setImmutable()
      Makes this instance immutable.
    • isImmutable

      public final boolean isImmutable()
      Checks to see whether or not this instance is immutable. This is the same as calling !isMutable().
      Returns:
      true iff this instance is immutable
    • isMutable

      public final boolean isMutable()
      Checks to see whether or not this instance is mutable.
      Returns:
      true iff this instance is mutable
    • throwIfImmutable

      public final void throwIfImmutable()
      Throws MutabilityException if this instance is immutable.
    • throwIfMutable

      public final void throwIfMutable()
      Throws MutabilityException if this instance is mutable.