blob: 45a27b95e2f540fb67fa90324ff3f062076df533 [file] [log] [blame]
Simon Huntc13082f2016-08-03 21:20:23 -07001/*
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
17package org.onosproject.ui.model.topo;
18
19import org.onosproject.net.region.RegionId;
20
21
22/**
23 * Designates a link between two region nodes.
24 */
25public 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
39 * @param id canonicalized link identifier
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 Hunt3d712522016-08-11 11:20:44 -070061 // no ports for end-points A and B
62
Simon Huntc13082f2016-08-03 21:20:23 -070063 /**
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}