blob: 02989afa9f2105ba9f539821b2031b6746e59e30 [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;
20import java.util.Objects;
21
22/**
BitOhenryd50bf822015-10-26 13:52:57 +080023 * The class representing a datapathid.
24 * This class is immutable.
CNlucius74fd4942015-07-20 14:28:04 +080025 */
26public final class OvsdbDatapathId {
27 private final String value;
28
29 /**
BitOhenryd50bf822015-10-26 13:52:57 +080030 * Constructor from a String.
CNlucius74fd4942015-07-20 14:28:04 +080031 *
32 * @param value the datapathid to use
33 */
34 public OvsdbDatapathId(String value) {
35 checkNotNull(value, "value is not null");
36 this.value = value;
37 }
38
39 /**
BitOhenryd50bf822015-10-26 13:52:57 +080040 * Gets the value of datapathid.
CNlucius74fd4942015-07-20 14:28:04 +080041 *
BitOhenryd50bf822015-10-26 13:52:57 +080042 * @return the value of datapathid
CNlucius74fd4942015-07-20 14:28:04 +080043 */
44 public String value() {
45 return value;
46 }
47
48 @Override
49 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070050 return value.hashCode();
CNlucius74fd4942015-07-20 14:28:04 +080051 }
52
53 @Override
54 public boolean equals(Object obj) {
55 if (this == obj) {
56 return true;
57 }
58 if (obj instanceof OvsdbDatapathId) {
59 final OvsdbDatapathId otherDatapathId = (OvsdbDatapathId) obj;
60 return Objects.equals(this.value, otherDatapathId.value);
61 }
62 return false;
63 }
64
65 @Override
66 public String toString() {
67 return toStringHelper(this).add("value", value).toString();
68 }
69}