Class AbstractObserver<T>
java.lang.Object
io.github.astrapi69.design.pattern.observer.AbstractObserver<T>
- Type Parameters:
T
- the generic type of the observable object
- All Implemented Interfaces:
ActionCommand
,Observer<T>
A generic implementation of the Observer pattern This abstract class implements the
Observer
and ActionCommand
interfaces, providing a basic framework for observers
in the Observer design pattern-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractObserver
(Subject<T, Observer<T>> subject) Constructor for a new observer object -
Method Summary
Modifier and TypeMethodDescriptionGets the current observable objectvoid
This method is called to notify the observer of changes in the observable object Implementing classes should define the specific behavior that occurs when the observable object changesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.astrapi69.design.pattern.observer.api.ActionCommand
execute
-
Field Details
-
subject
The subject being observed
-
-
Constructor Details
-
AbstractObserver
Constructor for a new observer object- Parameters:
subject
- the subject to observe
-
-
Method Details
-
getObservable
Gets the current observable object- Returns:
- the observable object
-
update
This method is called to notify the observer of changes in the observable object Implementing classes should define the specific behavior that occurs when the observable object changes
-