blob: 7c3456cb198d4c241952c7e8027f4db5f2e31f00 [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
61 /**
62 * Returns the identity of the first region.
63 *
64 * @return first region ID
65 */
66 public RegionId regionA() {
67 return regionA;
68 }
69
70 /**
71 * Returns the identity of the second region.
72 *
73 * @return second region ID
74 */
75 public RegionId regionB() {
76 return regionB;
77 }
78}