1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.linecorp.centraldogma.server.metadata;
18
19 import static com.linecorp.centraldogma.internal.Util.APP_IDENTITY_EMAIL_SUFFIX;
20 import static java.util.Objects.requireNonNull;
21
22 import com.google.common.base.MoreObjects;
23
24
25
26
27 public final class UserWithAppIdentity extends User {
28
29 private static final long serialVersionUID = 6021146546653491444L;
30
31 private final AppIdentity appIdentity;
32
33
34
35
36 public UserWithAppIdentity(AppIdentity appIdentity) {
37 super(requireNonNull(appIdentity, "appIdentity").appId(),
38 appIdentity.appId() + APP_IDENTITY_EMAIL_SUFFIX);
39 this.appIdentity = appIdentity;
40 }
41
42
43
44
45 public AppIdentity appIdentity() {
46 return appIdentity;
47 }
48
49 @Override
50 public boolean isSystemAdmin() {
51 return appIdentity.isSystemAdmin();
52 }
53
54 @Override
55 public int hashCode() {
56 return super.hashCode() * 31 + appIdentity.hashCode();
57 }
58
59 @Override
60 public boolean equals(Object o) {
61 if (this == o) {
62 return true;
63 }
64 if (!(o instanceof UserWithAppIdentity)) {
65 return false;
66 }
67 if (!super.equals(o)) {
68 return false;
69 }
70
71 final UserWithAppIdentity that = (UserWithAppIdentity) o;
72 return appIdentity.equals(that.appIdentity);
73 }
74
75 @Override
76 public String toString() {
77 return MoreObjects.toStringHelper(this)
78 .add("appIdentity", appIdentity)
79 .toString();
80 }
81 }