Package it.polimi.ingsw.utils
Class Observable<T>
- java.lang.Object
-
- it.polimi.ingsw.utils.Observable<T>
-
- Type Parameters:
T
- type of information that can be observed
- Direct Known Subclasses:
AppCLI
,Chat
,Connection
,Controller
,MainController
,Parser
,Pinger
public class Observable<T> extends Object
Custom Observable Class
-
-
Constructor Summary
Constructors Constructor Description Observable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObservers(Observer<T> observer)
Add an observervoid
addObservers(String key, Observer<T> observer)
Add an observer with a keyvoid
notify(ArrayList<String> targetList, T message)
Send data to specific observersvoid
notify(T message)
Send data to all observers
-
-
-
Method Detail
-
addObservers
public void addObservers(Observer<T> observer)
Add an observer- Parameters:
observer
- observer to add
-
addObservers
public void addObservers(String key, Observer<T> observer)
Add an observer with a key- Parameters:
key
- key to bind with the observerobserver
- observer to add
-
notify
public void notify(T message)
Send data to all observers- Parameters:
message
- data to send
-
-