blob: 817556829703b1eb35f1c145c2fbdc6426f365aa [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
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070019import org.onosproject.net.DeviceId;
20import org.onosproject.net.HostId;
21import org.onosproject.net.PortNumber;
22
Simon Huntc13082f2016-08-03 21:20:23 -070023/**
24 * Designates a link between a device and a host; that is, an edge link.
25 */
26public class UiEdgeLink extends UiLink {
27
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070028 private final HostId hostId;
29 private final DeviceId deviceId;
30 private final PortNumber port;
Simon Huntc13082f2016-08-03 21:20:23 -070031
32 /**
33 * Creates a UI link.
34 *
35 * @param topology parent topology
36 * @param id canonicalized link identifier
37 */
38 public UiEdgeLink(UiTopology topology, UiLinkId id) {
39 super(topology, id);
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070040 hostId = HostId.hostId(id.idA());
41 deviceId = (DeviceId) id.elementB();
42 port = id.portB();
Simon Huntc13082f2016-08-03 21:20:23 -070043 }
44
45 @Override
46 public String endPointA() {
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070047 return hostId.toString();
Simon Huntc13082f2016-08-03 21:20:23 -070048 }
49
50 @Override
51 public String endPointB() {
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070052 return deviceId.toString();
Simon Huntc13082f2016-08-03 21:20:23 -070053 }
54
Simon Hunt3d712522016-08-11 11:20:44 -070055 // no port for end-point A
56
57 @Override
58 public String endPortB() {
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070059 return port.toString();
Simon Hunt3d712522016-08-11 11:20:44 -070060 }
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070061
62 /**
63 * Returns the host identifier.
64 *
65 * @return host identifier
66 */
67 public HostId hostId() {
68 return hostId;
69 }
70
71 /**
72 * Returns the edge device identifier.
73 *
74 * @return device identifier
75 */
76 public DeviceId deviceId() {
77 return deviceId;
78 }
79
80 /**
81 * Returns the edge port number.
82 *
83 * @return edge port number
84 */
85 public PortNumber portNumber() {
86 return port;
87 }
88
Simon Huntc13082f2016-08-03 21:20:23 -070089}