unicon.matthews.admin.AdminUser.getLastModified()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 2
rs 10
eloc 2
1
package unicon.matthews.admin;
2
3
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4
import com.fasterxml.jackson.annotation.JsonInclude;
5
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
6
import org.apache.commons.lang3.builder.ToStringBuilder;
7
import org.apache.commons.lang3.builder.ToStringStyle;
8
import org.springframework.data.annotation.CreatedDate;
9
import org.springframework.data.annotation.Id;
10
import org.springframework.data.annotation.LastModifiedDate;
11
12
import javax.validation.constraints.NotNull;
13
import java.io.Serializable;
14
import java.time.LocalDateTime;
15
import java.util.Map;
16
17
@JsonIgnoreProperties(ignoreUnknown = true)
18
@JsonInclude(JsonInclude.Include.NON_EMPTY)
19
@JsonDeserialize(builder = AdminUser.Builder.class)
20
public final class AdminUser implements Serializable {
21
22
    private static final long serialVersionUID = 1L;
23
24
    @Id
25
    private String id;
26
27
    private String tenantId;
28
29
    private String orgId;
30
31
    private boolean superAdmin;
32
33
    @NotNull
34
    private String username;
35
36
    @NotNull
37
    private String password;
38
39
    private String emailAddress;
40
41
42
    private Map<String, String> metadata;
43
44
    @CreatedDate
45
    private LocalDateTime createdAt;
0 ignored issues
show
introduced by
Make this value-based field transient so it is not included in the serialization of this class.
Loading history...
46
47
    @LastModifiedDate
48
    private LocalDateTime lastModified;
0 ignored issues
show
introduced by
Make this value-based field transient so it is not included in the serialization of this class.
Loading history...
49
50
    private AdminUser() {
0 ignored issues
show
introduced by
"username" is marked "javax.validation.constraints.NotNull" but is not initialized in this constructor.
Loading history...
51
    }
52
53
    public String getId() {
54
        return id;
55
    }
56
57
    public String getTenantId() {
58
        return tenantId;
59
    }
60
61
    public String getOrgId() {
62
        return orgId;
63
    }
64
65
    public boolean isSuperAdmin() {
66
        return superAdmin;
67
    }
68
69
    public String getUsername() {
70
        return username;
71
    }
72
73
    public String getPassword() {
74
        return password;
75
    }
76
77
    public void setPassword(String password) {
78
        this.password = password;
79
    }
80
81
    public String getEmailAddress() {
82
        return emailAddress;
83
    }
84
85
    public Map<String, String> getMetadata() {
86
        return metadata;
87
    }
88
89
    public LocalDateTime getLastModified() {
90
        return lastModified;
91
    }
92
93
    public LocalDateTime getCreatedAt() {
94
        return createdAt;
95
    }
96
97
    @Override
98
    public String toString() {
99
        return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
100
    }
101
102
    @Override
103
    public int hashCode() {
104
        final int prime = 31;
105
        int result = 1;
106
        result = prime * result + ((id == null) ? 0 : id.hashCode());
107
        result = prime * result + ((lastModified == null) ? 0 : lastModified.hashCode());
108
        result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
109
        result = prime * result + ((orgId == null) ? 0 : orgId.hashCode());
110
        result = prime * result + ((password == null) ? 0 : password.hashCode());
111
        result = prime * result + (superAdmin ? 1231 : 1237);
112
        result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode());
113
        result = prime * result + ((username == null) ? 0 : username.hashCode());
114
        return result;
115
    }
116
117
    @Override
118
    public boolean equals(Object obj) {
119
        if (this == obj)
120
            return true;
121
        if (obj == null)
122
            return false;
123
        if (getClass() != obj.getClass())
124
            return false;
125
        AdminUser other = (AdminUser) obj;
126
        if (id == null) {
127
            if (other.id != null)
128
                return false;
129
        } else if (!id.equals(other.id))
130
            return false;
131
        if (lastModified == null) {
132
            if (other.lastModified != null)
133
                return false;
134
        } else if (!lastModified.equals(other.lastModified))
135
            return false;
136
        if (metadata == null) {
137
            if (other.metadata != null)
138
                return false;
139
        } else if (!metadata.equals(other.metadata))
140
            return false;
141
        if (orgId == null) {
142
            if (other.orgId != null)
143
                return false;
144
        } else if (!orgId.equals(other.orgId))
145
            return false;
146
        if (password == null) {
147
            if (other.password != null)
148
                return false;
149
        } else if (!password.equals(other.password))
150
            return false;
151
        if (superAdmin != other.superAdmin)
152
            return false;
153
        if (tenantId == null) {
154
            if (other.tenantId != null)
155
                return false;
156
        } else if (!tenantId.equals(other.tenantId))
157
            return false;
158
        if (username == null) {
159
            if (other.username != null)
160
                return false;
161
        } else if (!username.equals(other.username))
162
            return false;
163
        return true;
164
    }
165
166
    public static class Builder {
167
168
        private AdminUser _user = new AdminUser();
169
170
        public Builder withId(String id) {
171
            _user.id = id;
172
            return this;
173
        }
174
175
        public Builder withTenantId(String tenantId) {
176
            _user.tenantId = tenantId;
177
            return this;
178
        }
179
180
        public Builder withOrgId(String orgId) {
181
            _user.orgId = orgId;
182
            return this;
183
        }
184
185
        public Builder withUserName(String userName) {
186
            _user.username = userName;
187
            return this;
188
        }
189
190
        public Builder withPassword(String password) {
191
            _user.password = password;
192
            return this;
193
        }
194
195
        public Builder withEmailAddress(String emailAddress) {
196
            _user.emailAddress = emailAddress;
197
            return this;
198
        }
199
200
        public Builder withSuperAdmin(boolean superAdmin) {
201
            _user.superAdmin = superAdmin;
202
            return this;
203
        }
204
205
        public Builder withMetadata(Map<String, String> metadata) {
206
            _user.metadata = metadata;
207
            return this;
208
        }
209
210
        public AdminUser build() {
211
            return _user;
212
        }
213
    }
214
}