1 /*
2 * Copyright (C) 2017-2019 Centre National d'Etudes Spatiales (CNES).
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3.0 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19 package fr.cnes.doi.db.model;
20
21 /**
22 * DOI user model
23 *
24 * @author Jean-Christophe Malapert (jean-christophe.malapert@cnes.fr)
25 */
26 public class DOIUser {
27
28 /**
29 * User name.
30 */
31 private String username;
32
33 /**
34 * Indicates if the user is admin.
35 */
36 private Boolean admin;
37
38 /**
39 * Email of the user name.
40 */
41 private String email;
42
43 /**
44 * Returns the user name.
45 *
46 * @return the user name
47 */
48 public String getUsername() {
49 return username;
50 }
51
52 /**
53 * Sets the user name.
54 *
55 * @param username user name.
56 */
57 public void setUsername(final String username) {
58 this.username = username;
59 }
60
61 /**
62 * Returns True when the user is administrator otherwise False.
63 *
64 * @return True when the user is administrator otherwise False
65 */
66 public Boolean isAdmin() {
67 return admin;
68 }
69
70 /**
71 * Sets an administrator as admin.
72 *
73 * @param isAdmin True when the user is administrator otherwise False
74 */
75 public void setAdmin(final Boolean isAdmin) {
76 this.admin = isAdmin;
77 }
78
79 /**
80 * Sets the email of the user.
81 *
82 * @param email email
83 */
84 public void setEmail(final String email) {
85 this.email = email;
86 }
87
88 /**
89 * Returns the email.
90 *
91 * @return the email
92 */
93 public String getEmail() {
94 return email;
95 }
96
97 /**
98 * Tests if this object is equal to testuser.
99 *
100 * @param testuser DOIUser to test
101 * @return True when testuser is the same à this DOIUser
102 */
103 public Boolean isEqualTo(final DOIUser testuser) {
104 return this.username.equals(testuser.getUsername())
105 && this.admin.equals(testuser.isAdmin())
106 && this.email.equals(testuser.getEmail());
107 }
108
109 /**
110 * {@inheritDoc}
111 */
112 @Override
113 public String toString() {
114 return this.getUsername() + "_" + this.getEmail();
115 }
116 }