Simon Hunt | 1169c95 | 2017-06-05 11:20:11 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Simon Hunt | 1169c95 | 2017-06-05 11:20:11 -0700 | [diff] [blame] | 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 | |
| 18 | package org.onosproject.ui; |
| 19 | |
| 20 | import static com.google.common.base.Preconditions.checkNotNull; |
| 21 | |
| 22 | /** |
| 23 | * Encapsulates a session token pertaining to a Web UI websocket connection. |
| 24 | */ |
| 25 | public 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 | } |