blob: b4b3d49ec34a8448565f880fdb2bddc10784dfbb [file] [log] [blame]
Simon Hunt1169c952017-06-05 11:20:11 -07001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.onosproject.ui;
19
20import static com.google.common.base.Preconditions.checkNotNull;
21
22/**
23 * Encapsulates a session token pertaining to a Web UI websocket connection.
24 */
25public class UiSessionToken {
26
27 private final String token;
28
29 /**
30 * Creates a session token from the given string.
31 *
32 * @param token the token in string form
33 * @throws NullPointerException if token is null
34 */
35 public UiSessionToken(String token) {
36 this.token = checkNotNull(token);
37 }
38
39 @Override
40 public String toString() {
41 return token;
42 }
43
44 @Override
45 public boolean equals(Object o) {
46 if (this == o) {
47 return true;
48 }
49 if (o == null || getClass() != o.getClass()) {
50 return false;
51 }
52
53 UiSessionToken that = (UiSessionToken) o;
54 return token.equals(that.token);
55 }
56
57 @Override
58 public int hashCode() {
59 return token.hashCode();
60 }
61}