2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.sdc.ci.tests.datatypes;
23 import org.joda.time.DateTime;
24 import org.joda.time.DateTimeZone;
27 public static final String FORCE_DELETE_HEADER_FLAG = "FORCE_DELETE";
29 private String firstName;
31 private String lastName;
33 private String userId;
39 private Long lastLoginTime;
45 public User(String firstName, String lastName, String userId, String emailAddress, String role,
47 this.firstName = firstName;
48 this.lastName = lastName;
50 this.email = emailAddress;
52 this.lastLoginTime = lastLoginTime;
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();
66 public User(User aUser) {
67 this(aUser.getFirstName(), aUser.getLastName(), aUser.getUserId(), aUser.getEmail(), aUser.getRole(),
68 aUser.getLastLoginTime());
71 public String getFirstName() {
75 public void setFirstName(String firstName) {
76 this.firstName = firstName;
79 public String getLastName() {
83 public void setLastName(String lastName) {
84 this.lastName = lastName;
87 public String getUserId() {
91 public void setUserId(String userId) {
95 public String getEmail() {
99 public void setEmail(String email) {
103 public String getRole() {
107 public void setRole(String role) {
111 public String getFullName() {
112 return this.getFirstName() + " " + this.getLastName();
115 public void setLastLoginTime() {
116 DateTime now = new DateTime(DateTimeZone.UTC);
117 this.lastLoginTime = now.getMillis();
120 public void setLastLoginTime(Long time) {
121 this.lastLoginTime = time;
124 public Long getLastLoginTime() {
125 return this.lastLoginTime;
129 public int hashCode() {
130 final int prime = 31;
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());
142 public boolean equals(Object obj) {
147 if (getClass() != obj.getClass())
149 User other = (User) obj;
150 if (userId == null) {
151 if (other.userId != null)
153 } else if (!userId.equals(other.userId))
156 if (other.email != null)
158 } else if (!email.equals(other.email))
160 if (firstName == null) {
161 if (other.firstName != null)
163 } else if (!firstName.equals(other.firstName))
165 if (lastName == null) {
166 if (other.lastName != null)
168 } else if (!lastName.equals(other.lastName))
171 if (other.role != null)
173 } else if (!role.equals(other.role))
175 if (lastLoginTime == null) {
176 if (other.lastLoginTime != null)
178 } else if (!lastLoginTime.equals(other.lastLoginTime))
184 public String toString() {
185 return "User [firstName=" + firstName + ", lastName=" + lastName + ", userId=" + userId + ", email=" + email
186 + ", role=" + role + ", last login time=" + lastLoginTime + "]";