1 package com.atlassian.sal.api.events;
2
3 import javax.annotation.Nullable;
4
5 import static com.google.common.base.Preconditions.checkNotNull;
6
7 public abstract class AbstractSessionEvent
8 {
9 private static final String SESSION_ID_NULL_MSG = "Session ID must be supplied";
10
11 protected final String sessionId;
12 protected final String userName;
13
14 protected AbstractSessionEvent(final String sessionId, final String userName)
15 {
16 this.sessionId = checkNotNull(sessionId, SESSION_ID_NULL_MSG);
17 this.userName = userName;
18 }
19
20 public String getSessionId()
21 {
22 return sessionId;
23 }
24
25 @Nullable
26 public String getUserName()
27 {
28 return userName;
29 }
30
31 public abstract static class Builder
32 {
33 protected String sessionId;
34 protected String userName;
35
36 protected Builder()
37 {
38 }
39
40 public Builder sessionId(final String sessionId)
41 {
42 this.sessionId = checkNotNull(sessionId, SESSION_ID_NULL_MSG);
43 return this;
44 }
45
46 public Builder userName(@Nullable final String userName)
47 {
48 this.userName = userName;
49 return this;
50 }
51
52 public abstract AbstractSessionEvent build();
53 }
54 }