blob: 564c45a5b7fc74334a82eba87a04a1dc70edbdf1 [file] [log] [blame]
Jonathan Hart612651f2019-11-25 09:21:43 -08001/*
2 * Copyright 2020-present Open Networking Foundation
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
17package org.opencord.aaa.impl;
18
19import java.util.Objects;
20
Matteo Scandolobbc1ffb2020-10-16 15:56:20 -070021import static com.google.common.base.MoreObjects.toStringHelper;
22
Jonathan Hart612651f2019-11-25 09:21:43 -080023/**
24 * An identifier for an authentication request.
25 */
26public final class RequestIdentifier {
27
28 private byte identifier;
29
30 /**
31 * Creates a new request identifier.
32 *
33 * @param identifier id number
34 */
Matteo Scandolobbc1ffb2020-10-16 15:56:20 -070035 public RequestIdentifier(byte identifier) {
Jonathan Hart612651f2019-11-25 09:21:43 -080036 this.identifier = identifier;
37 }
38
39 /**
40 * Returns the id number.
41 *
42 * @return id
43 */
44 public byte identifier() {
45 return this.identifier;
46 }
47
48 /**
49 * Creates a new request identifier.
50 *
51 * @param identifier id number
52 * @return identifier
53 */
54 public static RequestIdentifier of(byte identifier) {
55 return new RequestIdentifier(identifier);
56 }
57
Matteo Scandolobbc1ffb2020-10-16 15:56:20 -070058 @Override
Jonathan Hart612651f2019-11-25 09:21:43 -080059 public boolean equals(Object other) {
60 if (!(other instanceof RequestIdentifier)) {
61 return false;
62 }
63
64 RequestIdentifier that = (RequestIdentifier) other;
65
66 return identifier == that.identifier;
67 }
68
Matteo Scandolobbc1ffb2020-10-16 15:56:20 -070069 @Override
Jonathan Hart612651f2019-11-25 09:21:43 -080070 public int hashCode() {
71 return Objects.hashCode(identifier);
72 }
Matteo Scandolobbc1ffb2020-10-16 15:56:20 -070073
74 @Override
75 public String toString() {
76 return toStringHelper(getClass())
77 .add("identifier", Byte.toString(identifier))
78 .toString();
79 }
Jonathan Hart612651f2019-11-25 09:21:43 -080080}