blob: 3577aaef32ca9627a629d5bb0a9206e7224fdbe0 [file] [log] [blame]
YuanyouZhangf26445a2015-07-22 17:13:18 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
YuanyouZhangf26445a2015-07-22 17:13:18 +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;
19import static com.google.common.base.Preconditions.checkNotNull;
20
21import java.util.Objects;
22
23/**
BitOhenry6e204892015-11-04 22:09:04 +080024 * The class representing a port type.
25 * This class is immutable.
YuanyouZhangf26445a2015-07-22 17:13:18 +080026 */
27public class OvsdbPortType {
28
29 private final String value;
30
31 /**
BitOhenry6e204892015-11-04 22:09:04 +080032 * Constructor from a String.
YuanyouZhangf26445a2015-07-22 17:13:18 +080033 *
34 * @param value the port type to use
35 */
36 public OvsdbPortType(String value) {
37 checkNotNull(value, "value is not null");
38 this.value = value;
39 }
40
41 /**
BitOhenry6e204892015-11-04 22:09:04 +080042 * Gets the value of port type.
YuanyouZhangf26445a2015-07-22 17:13:18 +080043 *
BitOhenry6e204892015-11-04 22:09:04 +080044 * @return the value of port type
YuanyouZhangf26445a2015-07-22 17:13:18 +080045 */
46 public String value() {
47 return value;
48 }
49
50 @Override
51 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070052 return value.hashCode();
YuanyouZhangf26445a2015-07-22 17:13:18 +080053 }
54
55 @Override
56 public boolean equals(Object obj) {
57 if (this == obj) {
58 return true;
59 }
60 if (obj instanceof OvsdbPortType) {
61 final OvsdbPortType otherOvsdbPortType = (OvsdbPortType) obj;
62 return Objects.equals(this.value, otherOvsdbPortType.value);
63 }
64 return false;
65 }
66
67 @Override
68 public String toString() {
69 return toStringHelper(this).add("value", value).toString();
70 }
71}