org.jquantlib.util
Class LazyObject
- java.lang.Object
-
- org.jquantlib.util.LazyObject
-
- All Implemented Interfaces:
- Observable, Observer
- Direct Known Subclasses:
- Instrument, PiecewiseYieldCurve
public abstract class LazyObject extends java.lang.Object implements Observer, Observable
Framework for calculation on demand and result caching.- See Also:
- Lazy Object Design Pattern,
Observer,Observable
-
-
Constructor Summary
Constructors Constructor and Description LazyObject()Creates a new LazyObject instance which is potentially able to perform calculations on demand every time it observes a change in aObservableobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddObserver(Observer observer)Attaches a observer to the Observable.intcountObservers()Counts how many Observers were attached to this class.voiddeleteObserver(Observer observer)Detaches a previously attached observer to the observable.voiddeleteObservers()Detaches all previously attached observer to the observable.voidfreeze()This method constrains the object to return the presently cached results on successive invocations, even if arguments upon which they depend should change.java.util.List<Observer>getObservers()Returns list of observers registered with the Observable.voidnotifyObservers()Notifies all attached observers about changes in the observable.voidnotifyObservers(java.lang.Object arg)Notifies all attached observers about changes in the observable.voidrecalculate()This method force the recalculation of any results which would otherwise be cached.voidunfreeze()This method reverts the effect of the freeze method, thus re-enabling recalculations.voidupdate()This method is called whenever the observed object is changed.
-
-
-
Constructor Detail
-
LazyObject
public LazyObject()
Creates a new LazyObject instance which is potentially able to perform calculations on demand every time it observes a change in aObservableobject. A LazyObject is anObserverand anObservableat the same time.
-
-
Method Detail
-
recalculate
public final void recalculate()
This method force the recalculation of any results which would otherwise be cached.
-
freeze
public final void freeze()
This method constrains the object to return the presently cached results on successive invocations, even if arguments upon which they depend should change.
-
unfreeze
public final void unfreeze()
This method reverts the effect of the freeze method, thus re-enabling recalculations.
-
update
public void update()
Description copied from interface:ObserverThis method is called whenever the observed object is changed.
-
addObserver
public final void addObserver(Observer observer)
Description copied from interface:ObservableAttaches a observer to the Observable. After attachment the observer gets informed about changes in the Observable.- Specified by:
addObserverin interfaceObservable- Parameters:
observer- The observer to attach to the observable
-
countObservers
public final int countObservers()
Description copied from interface:ObservableCounts how many Observers were attached to this class.- Specified by:
countObserversin interfaceObservable- Returns:
- the number of Observers
- See Also:
Observer
-
deleteObserver
public final void deleteObserver(Observer observer)
Description copied from interface:ObservableDetaches a previously attached observer to the observable. After detachment the observer does no longer receive change notifications from the observable.- Specified by:
deleteObserverin interfaceObservable- Parameters:
observer- The observer to detach from the observable
-
notifyObservers
public final void notifyObservers()
Description copied from interface:ObservableNotifies all attached observers about changes in the observable.- Specified by:
notifyObserversin interfaceObservable
-
notifyObservers
public final void notifyObservers(java.lang.Object arg)
Description copied from interface:ObservableNotifies all attached observers about changes in the observable.- Specified by:
notifyObserversin interfaceObservable- Parameters:
arg- an arbitrary Object to be passed to the Observer
-
deleteObservers
public final void deleteObservers()
Description copied from interface:ObservableDetaches all previously attached observer to the observable. After detachment observers do not longer receive change notifications from the observable.- Specified by:
deleteObserversin interfaceObservable
-
getObservers
public final java.util.List<Observer> getObservers()
Description copied from interface:ObservableReturns list of observers registered with the Observable. List returned is unmodifiable list.- Specified by:
getObserversin interfaceObservable- Returns:
- list of observers
-
-
DataMelt 3.0 © DataMelt by jWork.ORG