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