janani b | f41dec3 | 2017-03-24 18:44:07 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
janani b | f41dec3 | 2017-03-24 18:44:07 +0530 | [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 | |
| 17 | package org.onosproject.l3vpn.netl3vpn; |
| 18 | |
| 19 | import java.util.HashMap; |
| 20 | import java.util.Map; |
| 21 | |
| 22 | /** |
| 23 | * Representation of BGP information which contains the protocol info and the |
| 24 | * VPN name. |
| 25 | */ |
| 26 | public class BgpInfo { |
| 27 | |
| 28 | /** |
| 29 | * Map of route protocol and the protocol info for the BGP info. |
| 30 | */ |
| 31 | private Map<RouteProtocol, ProtocolInfo> protocolInfo; |
| 32 | |
| 33 | /** |
| 34 | * VPN name, to which the BGP info belongs. |
| 35 | */ |
| 36 | private String vpnName; |
| 37 | |
| 38 | /** |
| 39 | * Constructs BGP info. |
| 40 | */ |
| 41 | public BgpInfo() { |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Returns the map of protocol info associated with the BGP info. |
| 46 | * |
| 47 | * @return protocol info map. |
| 48 | */ |
janani b | 35f6cbc | 2017-03-24 21:56:58 +0530 | [diff] [blame] | 49 | public Map<RouteProtocol, ProtocolInfo> protocolInfo() { |
janani b | f41dec3 | 2017-03-24 18:44:07 +0530 | [diff] [blame] | 50 | return protocolInfo; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Sets the map of protocol info with route protocol as key value. |
| 55 | * |
| 56 | * @param protocolInfo protocol info map |
| 57 | */ |
janani b | 35f6cbc | 2017-03-24 21:56:58 +0530 | [diff] [blame] | 58 | public void protocolInfo(Map<RouteProtocol, ProtocolInfo> protocolInfo) { |
janani b | f41dec3 | 2017-03-24 18:44:07 +0530 | [diff] [blame] | 59 | this.protocolInfo = protocolInfo; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Adds a protocol info with route protocol as key to the map. |
| 64 | * |
| 65 | * @param route route protocol |
| 66 | * @param info protocol info |
| 67 | */ |
janani b | 35f6cbc | 2017-03-24 21:56:58 +0530 | [diff] [blame] | 68 | public void addProtocolInfo(RouteProtocol route, ProtocolInfo info) { |
janani b | f41dec3 | 2017-03-24 18:44:07 +0530 | [diff] [blame] | 69 | if (protocolInfo == null) { |
| 70 | protocolInfo = new HashMap<>(); |
| 71 | } |
| 72 | protocolInfo.put(route, info); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Returns the VPN name of the BGP info. |
| 77 | * |
| 78 | * @return VPN name |
| 79 | */ |
janani b | 35f6cbc | 2017-03-24 21:56:58 +0530 | [diff] [blame] | 80 | public String vpnName() { |
janani b | f41dec3 | 2017-03-24 18:44:07 +0530 | [diff] [blame] | 81 | return vpnName; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Sets the VPN name. |
| 86 | * |
| 87 | * @param vpnName VPN name |
| 88 | */ |
janani b | 35f6cbc | 2017-03-24 21:56:58 +0530 | [diff] [blame] | 89 | public void vpnName(String vpnName) { |
janani b | f41dec3 | 2017-03-24 18:44:07 +0530 | [diff] [blame] | 90 | this.vpnName = vpnName; |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public String toString() { |
| 95 | return "VPN name : " + vpnName; |
| 96 | } |
| 97 | } |
| 98 | |