PageRenderTime 632ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/IzvorniKod/ZOOVrt/app/src/main/java/com/example/natkobiscan/zoovrt/model/database/User.java

https://gitlab.com/dvesinger/TheFault
Java | 265 lines | 94 code | 35 blank | 136 comment | 0 complexity | 34eec60bfdf07bc07889e7f6bd08cd63 MD5 | raw file
  1. package com.example.natkobiscan.zoovrt.model.database;
  2. import com.google.gson.annotations.SerializedName;
  3. import java.io.Serializable;
  4. import java.util.regex.Pattern;
  5. /**
  6. * Abstract class that models general user attributes.
  7. *
  8. * @author Domagoj Pluscec
  9. * @version v2.0, 28.12.2016., Vedran Ivanusic
  10. */
  11. public abstract class User implements Serializable {
  12. /**
  13. * Valid email address regex.
  14. */
  15. public static final Pattern VALID_EMAIL_ADDRESS_REGEX =
  16. Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
  17. /**
  18. * Number that JVM uses for serialization.
  19. */
  20. private static final long serialVersionUID = 6308921911018631089L;
  21. /**
  22. * Username.
  23. */
  24. @SerializedName("korisnicko_ime")
  25. private String korisnickoIme;
  26. /**
  27. * User email.
  28. */
  29. @SerializedName("email")
  30. private String email;
  31. /**
  32. * User birth year.
  33. */
  34. @SerializedName("godinaRod")
  35. private Integer godinaRod;
  36. /**
  37. * User's city.
  38. */
  39. @SerializedName("grad")
  40. private String grad;
  41. /**
  42. * User's name.
  43. */
  44. @SerializedName("ime")
  45. private String ime;
  46. /**
  47. * User's password.
  48. */
  49. @SerializedName("lozinka")
  50. private String lozinka;
  51. /**
  52. * User's last name.
  53. */
  54. @SerializedName("prezime")
  55. private String prezime;
  56. /**
  57. * User's permissions.
  58. */
  59. private Permissions ovlasti;
  60. /**
  61. * Constructor that initializes user with given parameters.
  62. *
  63. * @param korisnickoIme username
  64. * @param lozinka password
  65. * @param ime name
  66. * @param prezime last name
  67. * @param email email address
  68. * @param godinaRod birth year
  69. * @param grad city
  70. * @param ovlasti user's permission
  71. */
  72. public User(String korisnickoIme, String lozinka, String ime, String prezime, String email, Integer godinaRod, String grad, Permissions ovlasti) {
  73. this.korisnickoIme = korisnickoIme;
  74. this.email = email;
  75. this.godinaRod = godinaRod;
  76. this.grad = grad;
  77. this.ime = ime;
  78. this.lozinka = lozinka;
  79. this.prezime = prezime;
  80. this.ovlasti = ovlasti;
  81. }
  82. /**
  83. * Java bean empty constructor.
  84. */
  85. public User() {
  86. }
  87. /**
  88. * Constructor that initializes user with general user attributes.
  89. *
  90. * @param user user instance
  91. */
  92. public User(User user) {
  93. this.korisnickoIme = user.korisnickoIme;
  94. this.email = user.email;
  95. this.godinaRod = user.godinaRod;
  96. this.grad = user.grad;
  97. this.ime = user.ime;
  98. this.lozinka = user.lozinka;
  99. this.prezime = user.prezime;
  100. this.ovlasti = user.ovlasti;
  101. }
  102. /**
  103. * Email getter method.
  104. *
  105. * @return user's email
  106. */
  107. public String getEmail() {
  108. return email;
  109. }
  110. /**
  111. * Method sets user's email address.
  112. *
  113. * @param email email address
  114. */
  115. public void setEmail(String email) {
  116. this.email = email;
  117. }
  118. /**
  119. * Birth year getter method.
  120. *
  121. * @return user's birth year
  122. */
  123. public Integer getGodinaRod() {
  124. return godinaRod;
  125. }
  126. /**
  127. * Method sets user's birthy year.
  128. *
  129. * @param godinaRod birth year
  130. */
  131. public void setGodinaRod(Integer godinaRod) {
  132. this.godinaRod = godinaRod;
  133. }
  134. /**
  135. * City getter method.
  136. *
  137. * @return user's city.
  138. */
  139. public String getGrad() {
  140. return grad;
  141. }
  142. /**
  143. * Method set's user city.
  144. *
  145. * @param grad city
  146. */
  147. public void setGrad(String grad) {
  148. this.grad = grad;
  149. }
  150. /**
  151. * Name getter method.
  152. *
  153. * @return user's name
  154. */
  155. public String getIme() {
  156. return ime;
  157. }
  158. /**
  159. * Method sets user's first name.
  160. *
  161. * @param ime first name
  162. */
  163. public void setIme(String ime) {
  164. this.ime = ime;
  165. }
  166. /**
  167. * Method for obtaining user's username.
  168. *
  169. * @return user's username
  170. */
  171. public String getKorisnickoIme() {
  172. return korisnickoIme;
  173. }
  174. /**
  175. * Method sets user's username.
  176. *
  177. * @param korisnickoIme username
  178. */
  179. public void setKorisnickoIme(String korisnickoIme) {
  180. this.korisnickoIme = korisnickoIme;
  181. }
  182. /**
  183. * Password getter method.
  184. *
  185. * @return user's password
  186. */
  187. public String getLozinka() {
  188. return lozinka;
  189. }
  190. /**
  191. * Method sets user password.
  192. *
  193. * @param lozinka password
  194. */
  195. public void setLozinka(String lozinka) {
  196. this.lozinka = lozinka;
  197. }
  198. /**
  199. * Permissions getter method.
  200. *
  201. * @return user's permissions
  202. */
  203. public Permissions getOvlasti() {
  204. return this.ovlasti;
  205. }
  206. /**
  207. * Method sets user permission.
  208. *
  209. * @param ovlasti permission
  210. */
  211. public void setOvlasti(Permissions ovlasti) {
  212. this.ovlasti = ovlasti;
  213. }
  214. /**
  215. * Method obtains user's last name.
  216. *
  217. * @return last name
  218. */
  219. public String getPrezime() {
  220. return prezime;
  221. }
  222. /**
  223. * Method sets user's last name.
  224. *
  225. * @param prezime last name
  226. */
  227. public void setPrezime(String prezime) {
  228. this.prezime = prezime;
  229. }
  230. }