Class Observable<S extends Observable<S>>

java.lang.Object
nz.ac.vuw.ecs.swen225.gp22.domain.Observable<S>
Direct Known Subclasses:
Entity

public abstract class Observable<S extends Observable<S>> extends Object
A class can extend this so an instance of it can be observed by Observer objects.
Author:
Abdul
  • Constructor Details

    • Observable

      public Observable()
  • Method Details

    • addObserver

      public void addObserver(Observer<S> observer)
      Adds an Observer to the list of observers.
      Parameters:
      observer - Observer to be added.
    • removeObserver

      public void removeObserver(Observer<S> observer)
      Removes an Observer from the list of observers.
      Parameters:
      observer - Observer to be removed.
    • updateObservers

      public void updateObservers()
      Calls the update() method for each observer attached to this object. This method suppresses the unchecked cast because type S is always a subtype of Observable with the generic type also being S, and the value of 'this' will also be a subtype of Observable with the generic type also being S, so the cast is safe.