de.matthiasmann.twl.model
Class AbstractOptionModel

java.lang.Object
  extended by de.matthiasmann.twl.model.AbstractOptionModel
All Implemented Interfaces:
BooleanModel, WithRunnableCallback
Direct Known Subclasses:
OptionBooleanModel, OptionEnumModel

public abstract class AbstractOptionModel
extends java.lang.Object
implements BooleanModel

A base class for option boolean model. This class handles the callback filtering from the source model. The callback on the source model is installed when the first callback on this model has been added, and is removed again when the last callback has been removed. This allows instances of AbstractOptionModel to be GCed when no longer needed. Without this dynamic subscription the callback on the source model would form a cycle of strong references between the AbstractOptionModel instance and it's source model which would prevent all instances from beeing GCed until the source model is also GCed.


Constructor Summary
AbstractOptionModel()
           
 
Method Summary
 void addCallback(java.lang.Runnable callback)
           
protected abstract  void installSrcCallback(java.lang.Runnable cb)
           
 void removeCallback(java.lang.Runnable callback)
           
protected abstract  void removeSrcCallback(java.lang.Runnable cb)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.matthiasmann.twl.model.BooleanModel
getValue, setValue
 

Constructor Detail

AbstractOptionModel

public AbstractOptionModel()
Method Detail

addCallback

public void addCallback(java.lang.Runnable callback)
Specified by:
addCallback in interface WithRunnableCallback

removeCallback

public void removeCallback(java.lang.Runnable callback)
Specified by:
removeCallback in interface WithRunnableCallback

installSrcCallback

protected abstract void installSrcCallback(java.lang.Runnable cb)

removeSrcCallback

protected abstract void removeSrcCallback(java.lang.Runnable cb)