Merge automation from ECOMP's repository
[vid.git] / vid-automation / src / main / java / org / onap / sdc / ci / tests / datatypes / User.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.sdc.ci.tests.datatypes;
22
23 import org.joda.time.DateTime;
24 import org.joda.time.DateTimeZone;
25
26 public class User {
27         public static final String FORCE_DELETE_HEADER_FLAG = "FORCE_DELETE";
28
29         private String firstName;
30
31         private String lastName;
32
33         private String userId;
34
35         private String email;
36
37         private String role;
38
39         private Long lastLoginTime;
40
41
42         public User() {
43         }
44
45         public User(String firstName, String lastName, String userId, String emailAddress, String role,
46                         Long lastLoginTime) {
47                 this.firstName = firstName;
48                 this.lastName = lastName;
49                 this.userId = userId;
50                 this.email = emailAddress;
51                 this.role = role;
52                 this.lastLoginTime = lastLoginTime;
53
54         }
55
56         public void copyData(User other) {
57                 this.firstName = other.getFirstName();
58                 this.lastName = other.getLastName();
59                 this.userId = other.getUserId();
60                 this.email = other.getEmail();
61                 this.role = other.getRole();
62                 this.lastLoginTime = other.getLastLoginTime();
63
64         }
65
66         public User(User aUser) {
67                 this(aUser.getFirstName(), aUser.getLastName(), aUser.getUserId(), aUser.getEmail(), aUser.getRole(),
68                                 aUser.getLastLoginTime());
69         }
70
71         public String getFirstName() {
72                 return firstName;
73         }
74
75         public void setFirstName(String firstName) {
76                 this.firstName = firstName;
77         }
78
79         public String getLastName() {
80                 return lastName;
81         }
82
83         public void setLastName(String lastName) {
84                 this.lastName = lastName;
85         }
86
87         public String getUserId() {
88                 return userId;
89         }
90
91         public void setUserId(String userId) {
92                 this.userId = userId;
93         }
94
95         public String getEmail() {
96                 return email;
97         }
98
99         public void setEmail(String email) {
100                 this.email = email;
101         }
102
103         public String getRole() {
104                 return role;
105         }
106
107         public void setRole(String role) {
108                 this.role = role;
109         }
110
111         public String getFullName() {
112                 return this.getFirstName() + " " + this.getLastName();
113         }
114
115         public void setLastLoginTime() {
116                 DateTime now = new DateTime(DateTimeZone.UTC);
117                 this.lastLoginTime = now.getMillis();
118         }
119
120         public void setLastLoginTime(Long time) {
121                 this.lastLoginTime = time;
122         }
123
124         public Long getLastLoginTime() {
125                 return this.lastLoginTime;
126         }
127
128         @Override
129         public int hashCode() {
130                 final int prime = 31;
131                 int result = 1;
132                 result = prime * result + ((userId == null) ? 0 : userId.hashCode());
133                 result = prime * result + ((email == null) ? 0 : email.hashCode());
134                 result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
135                 result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
136                 result = prime * result + ((role == null) ? 0 : role.hashCode());
137                 result = prime * result + ((lastLoginTime == null) ? 0 : lastLoginTime.hashCode());
138                 return result;
139         }
140
141         @Override
142         public boolean equals(Object obj) {
143                 if (this == obj)
144                         return true;
145                 if (obj == null)
146                         return false;
147                 if (getClass() != obj.getClass())
148                         return false;
149                 User other = (User) obj;
150                 if (userId == null) {
151                         if (other.userId != null)
152                                 return false;
153                 } else if (!userId.equals(other.userId))
154                         return false;
155                 if (email == null) {
156                         if (other.email != null)
157                                 return false;
158                 } else if (!email.equals(other.email))
159                         return false;
160                 if (firstName == null) {
161                         if (other.firstName != null)
162                                 return false;
163                 } else if (!firstName.equals(other.firstName))
164                         return false;
165                 if (lastName == null) {
166                         if (other.lastName != null)
167                                 return false;
168                 } else if (!lastName.equals(other.lastName))
169                         return false;
170                 if (role == null) {
171                         if (other.role != null)
172                                 return false;
173                 } else if (!role.equals(other.role))
174                         return false;
175                 if (lastLoginTime == null) {
176                         if (other.lastLoginTime != null)
177                                 return false;
178                 } else if (!lastLoginTime.equals(other.lastLoginTime))
179                         return false;
180                 return true;
181         }
182
183         @Override
184         public String toString() {
185                 return "User [firstName=" + firstName + ", lastName=" + lastName + ", userId=" + userId + ", email=" + email
186                                 + ", role=" + role + ", last login time=" + lastLoginTime + "]";
187         }
188
189 }