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