blob: 9c57b5df72b894e1723ffee437b01d90050d9076 [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;
19
20import java.util.Objects;
21
22/**
23 * The class representing a port number. This class is immutable.
24 */
25public final class OvsdbPortNumber {
26
27 private final long value;
28
29 /**
30 * Constructor from a long port number.
31 *
32 * @param value the port number to use
33 */
34 public OvsdbPortNumber(long value) {
35 this.value = value;
36 }
37
38 /**
39 * Gets the value of the port number.
40 *
41 * @return the value of the port number
42 */
43 public long 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 OvsdbPortNumber) {
58 final OvsdbPortNumber ovsdbPortNumber = (OvsdbPortNumber) obj;
59 return Objects.equals(this.value, ovsdbPortNumber.value);
60 }
61 return false;
62 }
63
64 @Override
65 public String toString() {
66 return toStringHelper(this).add("value", value).toString();
67 }
68}