Carmelo Cascone | 2ea177b | 2016-02-25 18:38:42 -0800 | [diff] [blame] | 1 | /* |
Carmelo Cascone | aa8b629 | 2016-04-13 14:27:06 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Carmelo Cascone | 2ea177b | 2016-02-25 18:38:42 -0800 | [diff] [blame] | 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 | */ |
| 16 | |
Carmelo Cascone | aa8b629 | 2016-04-13 14:27:06 -0700 | [diff] [blame] | 17 | package org.onosproject.bmv2.api.runtime; |
Carmelo Cascone | 2ea177b | 2016-02-25 18:38:42 -0800 | [diff] [blame] | 18 | |
| 19 | import com.google.common.base.MoreObjects; |
| 20 | import org.p4.bmv2.thrift.DevMgrPortInfo; |
| 21 | |
| 22 | import java.util.Collections; |
| 23 | import java.util.Map; |
| 24 | |
| 25 | /** |
| 26 | * Bmv2 representation of a switch port information. |
| 27 | */ |
| 28 | public 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 | } |