tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net; |
| 2 | |
| 3 | import org.onlab.onos.net.provider.ProviderId; |
| 4 | |
| 5 | import static com.google.common.base.Preconditions.checkArgument; |
| 6 | |
| 7 | /** |
| 8 | * Default edge link model implementation. |
| 9 | */ |
| 10 | public class DefaultEdgeLink extends DefaultLink implements EdgeLink { |
| 11 | |
| 12 | private final HostId hostId; |
| 13 | private final HostLocation hostLocation; |
| 14 | |
| 15 | /** |
| 16 | * Creates an edge link using the supplied information. |
| 17 | * |
| 18 | * @param providerId provider identity |
| 19 | * @param hostPoint host-side connection point |
| 20 | * @param hostLocation location where host attaches to the network |
| 21 | * @param isIngress true to indicated host-to-network direction; false |
| 22 | * for network-to-host direction |
| 23 | */ |
| 24 | public DefaultEdgeLink(ProviderId providerId, ConnectPoint hostPoint, |
| 25 | HostLocation hostLocation, boolean isIngress) { |
tom | cbefa23 | 2014-09-16 14:17:20 -0700 | [diff] [blame] | 26 | super(providerId, isIngress ? hostPoint : hostLocation, |
| 27 | isIngress ? hostLocation : hostPoint, Type.EDGE); |
tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 28 | checkArgument(hostPoint.elementId() instanceof HostId, |
| 29 | "Host point does not refer to a host ID"); |
| 30 | this.hostId = (HostId) hostPoint.elementId(); |
| 31 | this.hostLocation = hostLocation; |
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | public HostId hostId() { |
| 36 | return hostId; |
| 37 | } |
| 38 | |
| 39 | @Override |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 40 | public HostLocation hostLocation() { |
tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 41 | return hostLocation; |
| 42 | } |
| 43 | } |