blob: 41cd04591fba4041c562524983fa2f41b1146429 [file] [log] [blame]
tom80c0e5e2014-09-08 18:08:58 -07001package org.onlab.onos.net;
2
3import org.onlab.onos.net.provider.ProviderId;
4
5import static com.google.common.base.Preconditions.checkArgument;
6
7/**
8 * Default edge link model implementation.
9 */
10public 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) {
26 super(providerId, isIngress ? hostLocation : hostPoint,
27 isIngress ? hostPoint : hostLocation, Type.EDGE);
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
tom568581d2014-09-08 20:13:36 -070040 public HostLocation hostLocation() {
tom80c0e5e2014-09-08 18:08:58 -070041 return hostLocation;
42 }
43}