blob: 759ec499dffd1178926feb8cac45f585f92deff4 [file] [log] [blame]
CNlucius74fd4942015-07-20 14:28:04 +08001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.ovsdb.controller;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19import static com.google.common.base.Preconditions.checkNotNull;
20
21import java.util.Objects;
22
23/**
BitOhenry264f35a2015-11-03 20:58:39 +080024 * The class representing a bridge name.
25 * This class is immutable.
CNlucius74fd4942015-07-20 14:28:04 +080026 */
27public final class OvsdbBridgeName {
28
29 private final String value;
30
31 /**
BitOhenry264f35a2015-11-03 20:58:39 +080032 * Constructor from a String.
CNlucius74fd4942015-07-20 14:28:04 +080033 *
34 * @param value the bridge name to use
35 */
36 public OvsdbBridgeName(String value) {
37 checkNotNull(value, "value is not null");
38 this.value = value;
39 }
40
41 /**
BitOhenry264f35a2015-11-03 20:58:39 +080042 * Gets the value of bridge name.
CNlucius74fd4942015-07-20 14:28:04 +080043 *
44 * @return the value of the bridge name
45 */
46 public String value() {
47 return value;
48 }
49
50 @Override
51 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070052 return value.hashCode();
CNlucius74fd4942015-07-20 14:28:04 +080053 }
54
55 @Override
56 public boolean equals(Object obj) {
57 if (this == obj) {
58 return true;
59 }
60 if (obj instanceof OvsdbBridgeName) {
61 final OvsdbBridgeName otherBridgeName = (OvsdbBridgeName) obj;
62 return Objects.equals(this.value, otherBridgeName.value);
63 }
64 return false;
65 }
66
67 @Override
68 public String toString() {
69 return toStringHelper(this).add("value", value).toString();
70 }
71
72}