blob: 116f621714efbf6efc4da1b2631f691f93f7dac1 [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/**
24 * The class representing a tunnel name. This class is immutable.
25 */
26public final class OvsdbTunnelName {
27 private final String value;
28
29 /**
30 * Constructor from a String tunnel name.
31 *
32 * @param value the tunnel name to use
33 */
34 public OvsdbTunnelName(String value) {
35 checkNotNull(value, "value is not null");
36 this.value = value;
37 }
38
39 /**
40 * Gets the value of the tunnel name.
41 *
42 * @return the value of the tunnel name
43 */
44 public String value() {
45 return value;
46 }
47
48 @Override
49 public int hashCode() {
50 return Objects.hash(value);
51 }
52
53 @Override
54 public boolean equals(Object obj) {
55 if (this == obj) {
56 return true;
57 }
58 if (obj instanceof OvsdbTunnelName) {
59 final OvsdbTunnelName otherOvsdbTunnelName = (OvsdbTunnelName) obj;
60 return Objects.equals(this.value, otherOvsdbTunnelName.value);
61 }
62 return false;
63 }
64
65 @Override
66 public String toString() {
67 return toStringHelper(this).add("value", value).toString();
68 }
69}