Lines Matching defs:observer
27 * @param T The observer type.
31 * The list of observers. An observer can be in the list at most
37 * Adds an observer to the list. The observer cannot be null and it must not already
39 * @param observer the observer to register
40 * @throws IllegalArgumentException the observer is null
41 * @throws IllegalStateException the observer is already registered
43 public void registerObserver(T observer) {
44 if (observer == null) {
45 throw new IllegalArgumentException("The observer is null.");
48 if (mObservers.contains(observer)) {
49 throw new IllegalStateException("Observer " + observer + " is already registered.");
51 mObservers.add(observer);
56 * Removes a previously registered observer. The observer must not be null and it
58 * @param observer the observer to unregister
59 * @throws IllegalArgumentException the observer is null
60 * @throws IllegalStateException the observer is not yet registered
62 public void unregisterObserver(T observer) {
63 if (observer == null) {
64 throw new IllegalArgumentException("The observer is null.");
67 int index = mObservers.indexOf(observer);
69 throw new IllegalStateException("Observer " + observer + " was not registered.");