blob: c6be42633253cac6ea2d8a7ddb0c74c13ab598a4 [file] [log] [blame]
Carmelo Cascone2ea177b2016-02-25 18:38:42 -08001/*
Carmelo Casconeaa8b6292016-04-13 14:27:06 -07002 * Copyright 2016-present Open Networking Laboratory
Carmelo Cascone2ea177b2016-02-25 18:38:42 -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 */
16
Carmelo Casconeaa8b6292016-04-13 14:27:06 -070017package org.onosproject.bmv2.api.runtime;
Carmelo Cascone2ea177b2016-02-25 18:38:42 -080018
19import com.google.common.base.MoreObjects;
20import org.p4.bmv2.thrift.DevMgrPortInfo;
21
22import java.util.Collections;
23import java.util.Map;
24
25/**
26 * Bmv2 representation of a switch port information.
27 */
28public final class Bmv2PortInfo {
29
30 private final DevMgrPortInfo portInfo;
31
32 public Bmv2PortInfo(DevMgrPortInfo portInfo) {
33 this.portInfo = portInfo;
34 }
35
36 public final String ifaceName() {
37 return portInfo.getIface_name();
38 }
39
40 public final int portNumber() {
41 return portInfo.getPort_num();
42 }
43
44 public final boolean isUp() {
45 return portInfo.isIs_up();
46 }
47
48 public final Map<String, String> getExtraProperties() {
49 return Collections.unmodifiableMap(portInfo.getExtra());
50 }
51
52 @Override
53 public final String toString() {
54 return MoreObjects.toStringHelper(this)
55 .addValue(portInfo)
56 .toString();
57 }
58}