public class User extends BusinessEntity
| Modifier and Type | Class and Description |
|---|---|
static class |
User.Builder
A factory for a user's object.
|
static class |
User.Columns
A utility class that contains various strings to be used as keys to communicate with the
remote server.
|
static class |
User.Credentials
Class that handles user credentials.
|
| Constructor and Description |
|---|
User()
Default empty constructor.
|
User(org.json.JSONObject jsonObject)
Create a new User object based on a JSON Object.
|
User(java.lang.String json)
User's constructor.
|
User(User.Builder builder)
User's constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLanguage(Language language)
Add a language to the user's languages' list if it doesn't exists, otherwise do nothing.
|
boolean |
equals(java.lang.Object o) |
java.util.Date |
getBirthDate()
Get the user's birth date.
|
java.lang.String |
getCellphone()
Get the user's cellphone number.
|
User.Credentials |
getCredentials()
Get the user's credentials (username and password).
|
Document |
getDocument()
Get the user's current (last added and valid) document.
|
java.lang.String |
getEmail()
Get the user's email.
|
java.util.Set<Language> |
getLanguages()
Get all the user's languages.
|
java.lang.String |
getName()
Get the user's name.
|
java.lang.String |
getPassword()
Get the user's password.
|
Sex |
getSex()
Get the user's sex.
|
java.lang.String |
getSurname()
Get the user's surname.
|
java.lang.String |
getTaxCode()
Get the user's tax code.
|
java.lang.String |
getUsername()
Get the user's username.
|
UserType |
getUserType()
Get the user's type.
|
int |
hashCode() |
protected void |
loadFromJSONObject(org.json.JSONObject user)
Set the BusinessEntity's properties loading them from a JSONObject.
|
void |
removeLanguage(Language language)
Remove a language from the user's languages' list if it exists, otherwise do nothing.
|
void |
setBirthDate(java.util.Date birthDate)
Set the user's birth date.
|
void |
setCellphone(java.lang.String cellphone)
Set the user's cellphone number.
|
void |
setDocument(Document document)
Set the user's current (last added and valid) document.
|
void |
setEmail(java.lang.String email)
Set the user's email.
|
void |
setName(java.lang.String name)
Set the user's name
|
void |
setPassword(java.lang.String password)
Set the user's password.
|
void |
setSex(Sex sex)
Set the user's sex.
|
void |
setSurname(java.lang.String surname)
Set the user's surname.
|
void |
setTaxCode(java.lang.String taxCode)
Set the user's tax code.
|
void |
setUserType(UserType userType)
Set the user's type.
|
org.json.JSONObject |
toJSONObject()
Convert the user to a JSON Object.
|
static boolean |
validateEmail(java.lang.String emailInput)
A function that validates a email.
|
static boolean |
validateUsername(java.lang.String usernameInput)
A function that validates a username.
|
getJSONObject, toStringpublic User()
public User(org.json.JSONObject jsonObject)
{
"username": "test",
"tax_code": "testtaxcode",
"name": "Nome",
"surname": "Cognome",
"password": "password",
"email": "email@email.com",
"user_type": "1",
"cellphone": "0123456789",
"birth_date": "2010-01-20",
"sex": "male"
}
jsonObject - The JSON object from which data will be fetched.public User(java.lang.String json)
json - The json string.public User(User.Builder builder)
builder - The Builder.public boolean equals(java.lang.Object o)
equals in class java.lang.ObjectObject.equals(Object)public int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()protected void loadFromJSONObject(org.json.JSONObject user)
BusinessEntityloadFromJSONObject in class BusinessEntityuser - The JSONObject.BusinessEntity.loadFromJSONObject(JSONObject)public java.lang.String getName()
public void setName(java.lang.String name)
name - The new user's name.public java.lang.String getSurname()
public void setSurname(java.lang.String surname)
surname - The new user's surname.public java.lang.String getEmail()
public void setEmail(java.lang.String email)
email - The new user's email.public java.lang.String getPassword()
public void setPassword(java.lang.String password)
password - The new user's password.public Sex getSex()
public void setSex(Sex sex)
sex - The new user's sex.public java.lang.String getTaxCode()
public void setTaxCode(java.lang.String taxCode)
taxCode - The new user's tax code.public java.lang.String getUsername()
public UserType getUserType()
public void setUserType(UserType userType)
userType - The new user's type.public java.lang.String getCellphone()
public void setCellphone(java.lang.String cellphone)
cellphone - The new user's cellphone number.public java.util.Date getBirthDate()
public void setBirthDate(java.util.Date birthDate)
birthDate - The new user's birth date.public Document getDocument()
public void setDocument(Document document)
document - The new user's current document.public java.util.Set<Language> getLanguages()
public void addLanguage(Language language)
language - The language to be added.public void removeLanguage(Language language)
language - The language to be removed.public org.json.JSONObject toJSONObject()
toJSONObject in class BusinessEntitypublic User.Credentials getCredentials()
public static boolean validateUsername(java.lang.String usernameInput)
usernameInput - The username to check.public static boolean validateEmail(java.lang.String emailInput)
emailInput - The username to check.