public class SimpleObservable extends Object
Constructor and Description |
---|
SimpleObservable()
Creates a simple observable.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearChanged()
Indicates that this simple observable has no longer changed, or that it has already notified all of its observers
of its most recent change, so that the
hasChanged() method will now return false . |
Observer |
getObserver()
Returns the observer of this simple observable, if it is set.
|
boolean |
hasChanged()
Gets whether or not this simple observable has changed.
|
void |
notifyObserver()
Notifies the registered observer, if any.
|
protected void |
setChanged()
Marks this simple observable as having been changed.
|
void |
setObserver(Observer observer)
Sets the observer of this simple observable.
|
void |
unsetObserver()
Unsets the observer of this simple observable.
|
void |
unsetObserver(Observer observer)
Unsets the observer of this simple observable if it the same instance as the given observer.
|
protected void clearChanged()
hasChanged()
method will now return false
. This
method is called automatically by the notifyObserver()
method.@Nullable public Observer getObserver()
null
if it is not set.public boolean hasChanged()
true
if and only if the setChanged()
method has been called more recently than the
clearChanged()
method on this simple observable, false
otherwise.public void notifyObserver()
protected void setChanged()
hasChanged()
method will now return
true
.public void setObserver(Observer observer)
observer
- the observer to set.NullPointerException
- if the given observer is null
.public void unsetObserver()
public void unsetObserver(Observer observer)
observer
- the observer to unset.