Class ChatRoomUser<M extends Message<?>>
java.lang.Object
io.github.astrapi69.design.pattern.observer.chat.ChatRoomUser<M>
- Type Parameters:
M
- the generic type of the message that will be sent and observed in the chat room
- All Implemented Interfaces:
ActionCommand
,Observer<M>
,Serializable
public abstract class ChatRoomUser<M extends Message<?>>
extends Object
implements Observer<M>, ActionCommand, Serializable
The class
ChatRoomUser
represents a user in a chat room who can send and receive messages
This class implements Observer
to observe messages in the chat room,
ActionCommand
to define actions when a message is received, and Serializable
for
serialization support- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChatRoomUser
(ChatRoom<M> room, IUser<?> user) Instantiates a new chat room user -
Method Summary
Modifier and TypeMethodDescriptionGets the observable message currently observed by this userIUser<?>
getUser()
Gets the user associated with this chat room uservoid
Sends the given message to the chat roomvoid
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 chat room (subject) that this user is part of
-
-
Constructor Details
-
ChatRoomUser
Instantiates a new chat room user- Parameters:
room
- the chat room (subject) that this user is part ofuser
- the user associated with this chat room user
-
-
Method Details
-
getObservable
Gets the observable message currently observed by this user- Returns:
- the observable message
-
getUser
Gets the user associated with this chat room user- Returns:
- the user
-
send
Sends the given message to the chat room- Parameters:
message
- the message to be sent
-
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
-