| 38030 |
amit |
1 |
package com.spice.profitmandi.common.model;
|
|
|
2 |
|
|
|
3 |
import java.util.Objects;
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
* Staff member acting on a partner's behalf. A null Actor means the partner is acting themself.
|
|
|
7 |
*/
|
|
|
8 |
public final class Actor {
|
|
|
9 |
|
|
|
10 |
private final int authUserId;
|
|
|
11 |
private final String authUserEmail;
|
|
|
12 |
private final Long launchId;
|
|
|
13 |
|
|
|
14 |
private Actor(int authUserId, String authUserEmail, Long launchId) {
|
|
|
15 |
this.authUserId = authUserId;
|
|
|
16 |
this.authUserEmail = authUserEmail;
|
|
|
17 |
this.launchId = launchId;
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
public static Actor of(int authUserId, String authUserEmail, Long launchId) {
|
|
|
21 |
return new Actor(authUserId, authUserEmail, launchId);
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
/** Staff fields present in the token → Actor; otherwise null (the partner themself). */
|
|
|
25 |
public static Actor from(UserInfo userInfo) {
|
|
|
26 |
if (userInfo == null || userInfo.getAuthUserId() <= 0) {
|
|
|
27 |
return null;
|
|
|
28 |
}
|
|
|
29 |
return new Actor(userInfo.getAuthUserId(), userInfo.getAuthUserEmail(), userInfo.getLaunchId());
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public Actor withLaunch(long launchId) {
|
|
|
33 |
return new Actor(authUserId, authUserEmail, launchId);
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
public int getAuthUserId() {
|
|
|
37 |
return authUserId;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
public String getAuthUserEmail() {
|
|
|
41 |
return authUserEmail;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
public Long getLaunchId() {
|
|
|
45 |
return launchId;
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
@Override
|
|
|
49 |
public boolean equals(Object o) {
|
|
|
50 |
if (this == o) return true;
|
|
|
51 |
if (!(o instanceof Actor)) return false;
|
|
|
52 |
Actor actor = (Actor) o;
|
|
|
53 |
return authUserId == actor.authUserId && Objects.equals(launchId, actor.launchId);
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
@Override
|
|
|
57 |
public int hashCode() {
|
|
|
58 |
return Objects.hash(authUserId, launchId);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
@Override
|
|
|
62 |
public String toString() {
|
|
|
63 |
return "Actor[authUserId=" + authUserId + ", authUserEmail=" + authUserEmail + ", launchId=" + launchId + "]";
|
|
|
64 |
}
|
|
|
65 |
}
|