blob: a6f490f951eb02286ba009daaa2adc4b908b3b8f [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 Qos identity.
25 */
26@Beta
27public final class QosId {
28
29 private final String name;
30
31 private QosId(String name) {
32 this.name = checkNotNull(name);
33 }
34
35 public static QosId qosId(String name) {
36 return new QosId(name);
37 }
38
39 public String name() {
40 return name;
41 }
42
43 @Override
44 public int hashCode() {
45 return name.hashCode();
46 }
47
48 @Override
49 public boolean equals(Object obj) {
50 if (this == obj) {
51 return true;
52 }
53 if (obj instanceof QosId) {
54 final QosId that = (QosId) obj;
55 return this.getClass() == that.getClass() &&
56 Objects.equals(this.name, that.name);
57 }
58 return false;
59 }
60
61 @Override
62 public String toString() {
63 return name;
64 }
65}