blob: 6a536c7dfb826bff531962ce90ba19ef7d6d905c [file] [log] [blame]
Frank Wange11a98d2016-10-26 17:04:03 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Frank Wange11a98d2016-10-26 17:04:03 +08003 *
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 */
16package org.onosproject.net.behaviour;
17
18import com.google.common.annotations.Beta;
19import java.util.Objects;
20
21import static com.google.common.base.Preconditions.checkNotNull;
22
23/**
24 * Immutable representation of a Queue identity.
25 */
26@Beta
27public final class QueueId {
28 private final String name;
29
30 private QueueId(String name) {
31 this.name = checkNotNull(name);
32 }
33
34 public static QueueId queueId(String name) {
35 return new QueueId(name);
36 }
37
38 public String name() {
39 return name;
40 }
41
42 @Override
43 public int hashCode() {
44 return name.hashCode();
45 }
46
47 @Override
48 public boolean equals(Object obj) {
49 if (this == obj) {
50 return true;
51 }
52 if (obj instanceof QueueId) {
53 final QueueId that = (QueueId) obj;
54 return this.getClass() == that.getClass() &&
55 Objects.equals(this.name, that.name);
56 }
57 return false;
58 }
59
60 @Override
61 public String toString() {
62 return name;
63 }
64}