Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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.ui.model.topo; |
| 18 | |
| 19 | import org.onosproject.net.region.RegionId; |
| 20 | |
| 21 | |
| 22 | /** |
| 23 | * Designates a link between two region nodes. |
| 24 | */ |
| 25 | public class UiRegionLink extends UiLink { |
| 26 | |
| 27 | private static final String E_NOT_REGION_ID = |
| 28 | "UI link identifier not region to region"; |
| 29 | |
| 30 | // private (synthetic) region - region link |
| 31 | private final RegionId regionA; |
| 32 | private final RegionId regionB; |
| 33 | |
| 34 | /** |
| 35 | * Creates a region to region UI link. Note that it is expected that the |
| 36 | * link identifier is one that has region IDs as source and destination. |
| 37 | * |
| 38 | * @param topology parent topology |
Simon Hunt | b058249 | 2016-09-20 18:26:38 -0700 | [diff] [blame] | 39 | * @param id canonicalized link ID |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 40 | * @throws IllegalArgumentException if the link ID is not region-region |
| 41 | */ |
| 42 | public UiRegionLink(UiTopology topology, UiLinkId id) { |
| 43 | super(topology, id); |
| 44 | regionA = id.regionA(); |
| 45 | regionB = id.regionB(); |
| 46 | if (regionA == null || regionB == null) { |
| 47 | throw new IllegalArgumentException(E_NOT_REGION_ID); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public String endPointA() { |
| 53 | return regionA.id(); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public String endPointB() { |
| 58 | return regionB.id(); |
| 59 | } |
| 60 | |
Simon Hunt | 3d71252 | 2016-08-11 11:20:44 -0700 | [diff] [blame] | 61 | // no ports for end-points A and B |
| 62 | |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Returns the identity of the first region. |
| 65 | * |
| 66 | * @return first region ID |
| 67 | */ |
| 68 | public RegionId regionA() { |
| 69 | return regionA; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Returns the identity of the second region. |
| 74 | * |
| 75 | * @return second region ID |
| 76 | */ |
| 77 | public RegionId regionB() { |
| 78 | return regionB; |
| 79 | } |
| 80 | } |