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 | |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.HostId; |
| 21 | import org.onosproject.net.PortNumber; |
| 22 | |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 23 | /** |
| 24 | * Designates a link between a device and a host; that is, an edge link. |
| 25 | */ |
| 26 | public class UiEdgeLink extends UiLink { |
| 27 | |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 28 | private final HostId hostId; |
| 29 | private final DeviceId deviceId; |
| 30 | private final PortNumber port; |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 31 | |
| 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 Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 40 | hostId = HostId.hostId(id.idA()); |
| 41 | deviceId = (DeviceId) id.elementB(); |
| 42 | port = id.portB(); |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public String endPointA() { |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 47 | return hostId.toString(); |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public String endPointB() { |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 52 | return deviceId.toString(); |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Simon Hunt | 3d71252 | 2016-08-11 11:20:44 -0700 | [diff] [blame] | 55 | // no port for end-point A |
| 56 | |
| 57 | @Override |
| 58 | public String endPortB() { |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 59 | return port.toString(); |
Simon Hunt | 3d71252 | 2016-08-11 11:20:44 -0700 | [diff] [blame] | 60 | } |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 61 | |
| 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 Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 89 | } |