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 private static final String SESSION_ID_NULL_MSG = "Session ID must be supplied";
9
10 protected final String sessionId;
11 protected final String userName;
12
13 protected AbstractSessionEvent(final String sessionId, final String userName) {
14 this.sessionId = checkNotNull(sessionId, SESSION_ID_NULL_MSG);
15 this.userName = userName;
16 }
17
18 public String getSessionId() {
19 return sessionId;
20 }
21
22 @Nullable
23 public String getUserName() {
24 return userName;
25 }
26
27 public abstract static class Builder {
28 protected String sessionId;
29 protected String userName;
30
31 protected Builder() {
32 }
33
34 public Builder sessionId(final String sessionId) {
35 this.sessionId = checkNotNull(sessionId, SESSION_ID_NULL_MSG);
36 return this;
37 }
38
39 public Builder userName(@Nullable final String userName) {
40 this.userName = userName;
41 return this;
42 }
43
44 public abstract AbstractSessionEvent build();
45 }
46 }