blob: 33072b4ba42a821d39597b5c75b056b9a771a3cb [file] [log] [blame]
samuel8d6b0a92015-07-11 13:22:57 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samuel8d6b0a92015-07-11 13:22:57 +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 java.util.Objects;
19
20import com.google.common.base.MoreObjects;
21
22/**
23 * Represents for a bridge name.
24 */
25public final class BridgeName {
26
27 private final String name;
28
29 // Public construction is prohibited
30 private BridgeName(String name) {
31 this.name = name;
32 }
33
34 /**
35 * Creates a bridge name using the supplied string.
36 *
37 * @param name bridge name
38 * @return BridgeName
39 */
40 public static BridgeName bridgeName(String name) {
41 return new BridgeName(name);
42 }
43
44 /**
45 * Returns the bridge name string.
46 *
47 * @return name string
48 */
49 public String name() {
50 return name;
51 }
52
53 @Override
54 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070055 return name.hashCode();
samuel8d6b0a92015-07-11 13:22:57 +080056 }
57
58 @Override
59 public boolean equals(Object obj) {
60 if (this == obj) {
61 return true;
62 }
63 if (obj instanceof BridgeName) {
64 final BridgeName that = (BridgeName) obj;
65 return this.getClass() == that.getClass() &&
66 Objects.equals(this.name, that.name);
67 }
68 return false;
69 }
70
71 @Override
72 public String toString() {
73 return MoreObjects.toStringHelper(getClass())
74 .add("name", name)
75 .toString();
76 }
77
78}