public class User
extends java.lang.Object
Constructor and Description |
---|
User(java.lang.String lastName,
java.lang.String firstName,
java.lang.String nickname,
java.lang.String password,
java.util.List<Message> messages,
java.util.List<User> friends,
java.util.List<BroadcastList> broadcastLists)
A constructor to instantiate this class.
|
Modifier and Type | Method and Description |
---|---|
void |
addFriend(java.lang.String nickname)
add a friend to this user
|
java.util.List<BroadcastList> |
getBroadcastLists()
A getter for the list of broadcast lists owned by this user
|
java.lang.String |
getFirstName()
A getter for the first name
|
java.util.List<User> |
getFriends()
A getter for the list of friends of this user
|
java.lang.String |
getLastName()
a getter to return the last name
|
java.util.List<Message> |
getMessages()
A getter for the list of all the user messages both sent and received
|
java.lang.String |
getNickname()
A getter for the nickname
|
java.lang.String |
getPassword()
A getter for the user password
|
boolean |
isBroadcastList(java.lang.String nickname)
this method check whether supplied nickname is a broadcast list of this
user object
|
boolean |
isExistingNickname(java.lang.String nickname)
checks if the supplied nickname is associated with this user object.
|
boolean |
isFriend(java.lang.String nickname)
this method check whether supplied nickname is a friend of this user
object
|
boolean |
isMemberOfBroadcastList(java.lang.String nickname,
java.lang.String broadcastNickname)
checks whether the supplied nickname is part of the broadcastNickname
list both associated with this user object
|
void |
removeBroadcastList(java.lang.String broadcastNickname)
this method removes a broadcast list from this user object
|
void |
removeFriend(java.lang.String nickname)
remove a friend from this user object
|
void |
setBroadcastLists(java.util.List<BroadcastList> broadcastLists)
A setter for the list of broadcast lists owned by this user
|
void |
setFirstName(java.lang.String firstName)
A setter for the first name
|
void |
setFriends(java.util.List<User> friends)
A setter for the list of all friends of this user
|
void |
setLastName(java.lang.String lastName)
A setter for the last name
|
void |
setMessages(java.util.List<Message> messages)
A setter for the list of all the user messages
|
void |
setNickname(java.lang.String nickname)
A setter for the nickname
|
void |
setPassword(java.lang.String password)
A setter for the use password
|
public User(java.lang.String lastName, java.lang.String firstName, java.lang.String nickname, java.lang.String password, java.util.List<Message> messages, java.util.List<User> friends, java.util.List<BroadcastList> broadcastLists) throws WhatsAppRuntimeException
lastName
- last name of the userfirstName
- first name of the usernickname
- nickname of the user. This must be unique across all
userspassword
- password of the usermessages
- list of messages in the user's message list. This
includes both messages sent and received by the user.friends
- list of users who are friends of this userbroadcastLists
- list of broadcast lists that this user ownsWhatsAppRuntimeException
- if any of the strings passed to this
constructor are either null or empty or any of the lists passed to this
are null (they can be empty) throw an instance of this exception with the
message CANT_BE_EMPTY_OR_NULLpublic java.lang.String getLastName()
public void setLastName(java.lang.String lastName)
lastName
- - the last name of a userpublic java.lang.String getFirstName()
public void setFirstName(java.lang.String firstName)
firstName
- the first name of a userpublic java.lang.String getNickname()
public void setNickname(java.lang.String nickname)
nickname
- the nickname of a userpublic java.lang.String getPassword()
public void setPassword(java.lang.String password)
password
- the user passwordpublic java.util.List<Message> getMessages()
public void setMessages(java.util.List<Message> messages)
messages
- a list of all the user messagespublic java.util.List<User> getFriends()
public void setFriends(java.util.List<User> friends)
friends
- a list of all friends this user haspublic java.util.List<BroadcastList> getBroadcastLists()
public void setBroadcastLists(java.util.List<BroadcastList> broadcastLists)
broadcastLists
- the list of broadcast listspublic void removeBroadcastList(java.lang.String broadcastNickname) throws WhatsAppException
broadcastNickname
- the nickname of the broadcast list to removeWhatsAppException
- throw this with BCAST_LIST_DOES_NOT_EXIST as
the message if the broadcast list asked to remove does not existpublic boolean isFriend(java.lang.String nickname)
nickname
- the nickname of the user to be checked whether he is a
friendpublic boolean isBroadcastList(java.lang.String nickname)
nickname
- the nickname of the user to be checked whether it is a
broadcast list of this user objectpublic boolean isExistingNickname(java.lang.String nickname)
nickname
- the nickname to check againstpublic boolean isMemberOfBroadcastList(java.lang.String nickname, java.lang.String broadcastNickname)
nickname
- the nickname of the userbroadcastNickname
- the nickname of the broadcastListpublic void addFriend(java.lang.String nickname) throws WhatsAppException
nickname
- the nickname of the user who is to become a friend of
this user objectWhatsAppException
- throw a new instance of this exception with one
of the following messages: CANT_BE_OWN_FRIEND (if trying to add the the
same user to itself), ALREADY_A_FRIEND (if the nickname is already a
friend of this user), CANT_LOCATE (if the supplied nickname is not even
an existing global contact)public void removeFriend(java.lang.String nickname) throws WhatsAppException
nickname
- the nickname of the friend whom to remove as a friend of
this user objectWhatsAppException
- throw a new instance of this exception with
NOT_A_FRIEND (if nickname is not a friend of this user)