@Entity(name="User") public class User extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
protected String |
login |
protected String |
password |
| Constructor and Description |
|---|
User() |
User(String login,
String password,
String role)
Creates a new instance of
User |
User(String login,
String password,
String role,
List<Story> stories)
Creates a new instance of
User |
| Modifier and Type | Method and Description |
|---|---|
void |
addStory(Story story)
Adds a story directly to the stories collection of this user if the story
does not already belongs to this user.
|
void |
changePassword(String password)
Changes the password of the user.
|
List<Story> |
getCreatedStories()
Returns the list of stories that user creates
|
String |
getLogin()
Returns the login of the user
|
String |
getPassword()
Returns the password of the user
|
String |
getRole()
Returns the role of the user
|
boolean |
isAuthorofStory(Story story)
Checks if a story belongs to this user.
|
void |
removeStory(Story story)
Removes a story directly from the stories collection of this user.
|
void |
setCreatedStories(List<Story> createdStories)
Sets the list of stories that user creates.
|
void |
setLogin(String login)
Sets the login of the user.
|
void |
setPassword(String password)
Sets the password of the user.
|
void |
setRole(String role)
Sets the role of the user.
|
public User()
public User(String login, String password, String role)
Userlogin - the login of the user. This parameter must be a non empty and
non null string with a maximun length of 100 charspassword - the password of the user. This parameter must be a non empty
and non null string with a maximum length of 32 charsNullPointerException - if a null value is passed as the
value for any parameter.IllegalArgumentException - if value provided for any parameter is not
valid according to its description.public User(String login, String password, String role, List<Story> stories)
Userlogin - the login of the user. This parameter must be a non empty and
non null string with a maximun length of 100 charspassword - the password of the user. This parameter must be a non empty
and non null string with a maximum length of 32 charsstories - the stories that belong to this user. The list of stories can
be empty. null values are not supported.NullPointerException - if a null value is passed as the
value for any parameter.IllegalArgumentException - if value provided for any parameter is not
valid according to its description.public String getLogin()
public void setLogin(String login)
login - the login of the user. This parameter must be a non empty and
non null string with a maximun length of 100 charsNullPointerException - if a null value is passedIllegalArgumentException - if the length of the passed string is not
validpublic String getPassword()
public void setPassword(String password)
password - the password of the user. This parameter must be a non empty
and non null string with a maximun length of 32 charsNullPointerException - if a null value is passedIllegalArgumentException - if the length of the passed string is not
validpublic String getRole()
public void setRole(String role)
role - the role of the user. This parameter must be a non empty and
non null string with a maximun length of 10 charsNullPointerException - if a null value is passedIllegalArgumentException - if the length of the passed string is not
validpublic List<Story> getCreatedStories()
public void setCreatedStories(List<Story> createdStories)
createdStories - the of stories that user creates.The list of stories
can be empty. null values are not supported.NullPointerException - if a null value is passedpublic void addStory(Story story)
story - the story to add to this user. null values not
supported.NullPointerException - if the story is null.public void removeStory(Story story)
story - the story to remove from this user. null values not
supported.NullPointerException - if the story is null.public boolean isAuthorofStory(Story story)
story - the story whose property will be checked.true if the story belongs to this user. false
otherwise.public void changePassword(String password)
password - the raw password of the user. This parameter must be a
non null string with a minimum length of 6 chars.NullPointerException - if the password is null.IllegalArgumentException - if the length of the string passed is
not valid.Copyright © 2022. All rights reserved.