blob: 083ebd20080d964f1a744f24198ee1bbdaad6c29 [file] [log] [blame]
CNlucius74fd4942015-07-20 14:28:04 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
CNlucius74fd4942015-07-20 14:28:04 +08003 *
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/**
BitOhenryb8878132015-10-29 17:46:46 +080023 * The class representing a port number.
24 * This class is immutable.
CNlucius74fd4942015-07-20 14:28:04 +080025 */
26public final class OvsdbPortNumber {
27
28 private final long value;
29
30 /**
BitOhenryb8878132015-10-29 17:46:46 +080031 * Constructor from a long value.
CNlucius74fd4942015-07-20 14:28:04 +080032 *
33 * @param value the port number to use
34 */
35 public OvsdbPortNumber(long value) {
36 this.value = value;
37 }
38
39 /**
BitOhenryb8878132015-10-29 17:46:46 +080040 * Gets the value of port number.
CNlucius74fd4942015-07-20 14:28:04 +080041 *
BitOhenryb8878132015-10-29 17:46:46 +080042 * @return the value of port number
CNlucius74fd4942015-07-20 14:28:04 +080043 */
44 public long value() {
45 return value;
46 }
47
48 @Override
49 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070050 return Objects.hashCode(value);
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 OvsdbPortNumber) {
59 final OvsdbPortNumber ovsdbPortNumber = (OvsdbPortNumber) obj;
60 return Objects.equals(this.value, ovsdbPortNumber.value);
61 }
62 return false;
63 }
64
65 @Override
66 public String toString() {
67 return toStringHelper(this).add("value", value).toString();
68 }
69}