Frank Wang | e11a98d | 2016-10-26 17:04:03 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Frank Wang | e11a98d | 2016-10-26 17:04:03 +0800 | [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 | package org.onosproject.net.behaviour; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | import java.util.Objects; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | /** |
| 24 | * Immutable representation of a Queue identity. |
| 25 | */ |
| 26 | @Beta |
| 27 | public 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 | } |