public abstract class AbstractChangeable extends Object implements Changeable
Constructor and Description |
---|
AbstractChangeable() |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener cl)
Add a listener that will be informed of all changes.
|
void |
addChangeListener(ChangeListener cl,
ChangeType ct)
Add a listener that will be informed of changes of a given type.
|
protected ChangeSupport |
generateChangeSupport()
Called the first time a ChangeSupport object is needed.
|
protected ChangeSupport |
getChangeSupport(ChangeType ct)
Called to retrieve the ChangeSupport for this object.
|
protected boolean |
hasListeners()
Deprecated.
use hasListeners(ChangeType) if at all possible
|
protected boolean |
hasListeners(ChangeType ct)
Discover if we have listeners registered for a particular change type.
|
boolean |
isUnchanging(ChangeType ct)
A particular ChangeType can never be raised by this Changeable.
|
void |
removeChangeListener(ChangeListener cl)
Remove a listener that was interested in all types of changes.
|
void |
removeChangeListener(ChangeListener cl,
ChangeType ct)
Remove a listener that was interested in a specific types of changes.
|
public AbstractChangeable()
protected boolean hasListeners()
protected boolean hasListeners(ChangeType ct)
ct
- the ChangeType we are interested inprotected ChangeSupport generateChangeSupport()
protected ChangeSupport getChangeSupport(ChangeType ct)
Your implementation of this method should have the following structure:
It is usual for the forwarding listeners (someForwarder in this example) to
be transient and lazily instantiated. Be sure to register & unregister the
forwarder in the code that does the ChangeEvent handling in setter methods.
ChangeSupport cs = super.getChangeSupport(ct);
if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) {
someForwarder = new ChangeForwarder(...
this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange);
}
return cs;
public final void addChangeListener(ChangeListener cl)
Changeable
addChangeListener
in interface Changeable
cl
- the ChangeListener to addpublic final void addChangeListener(ChangeListener cl, ChangeType ct)
Changeable
addChangeListener
in interface Changeable
cl
- the ChangeListenerct
- the ChangeType it is to be informed ofpublic final void removeChangeListener(ChangeListener cl)
Changeable
removeChangeListener
in interface Changeable
cl
- a ChangeListener to removepublic final void removeChangeListener(ChangeListener cl, ChangeType ct)
Changeable
removeChangeListener
in interface Changeable
cl
- a ChangeListener to removect
- the ChangeType that it was interested inpublic final boolean isUnchanging(ChangeType ct)
Changeable
A particular ChangeType can never be raised by this Changeable.
If this returns true, then it is guaranteed that change events of this type (and all child types) can never under any circumstances be fired by this Changeable instance. If it returns false, that does not mean that this type of event will or even can be raised, but that it is worth registering listeners incase.
isUnchanging
in interface Changeable
ct
- the ChangeType to checkCopyright © 2014 BioJava. All rights reserved.