blob: 6074c67d05727a0abf438b19b1fa73fa8892a812 [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
tomf5d85d42014-10-02 05:27:56 -070023 * @param annotations optional key/value annotations
tom80c0e5e2014-09-08 18:08:58 -070024 */
25 public DefaultEdgeLink(ProviderId providerId, ConnectPoint hostPoint,
tomf5d85d42014-10-02 05:27:56 -070026 HostLocation hostLocation, boolean isIngress,
27 Annotations... annotations) {
tomcbefa232014-09-16 14:17:20 -070028 super(providerId, isIngress ? hostPoint : hostLocation,
tomf5d85d42014-10-02 05:27:56 -070029 isIngress ? hostLocation : hostPoint, Type.EDGE, annotations);
tom80c0e5e2014-09-08 18:08:58 -070030 checkArgument(hostPoint.elementId() instanceof HostId,
31 "Host point does not refer to a host ID");
32 this.hostId = (HostId) hostPoint.elementId();
33 this.hostLocation = hostLocation;
34 }
35
36 @Override
37 public HostId hostId() {
38 return hostId;
39 }
40
41 @Override
tom568581d2014-09-08 20:13:36 -070042 public HostLocation hostLocation() {
tom80c0e5e2014-09-08 18:08:58 -070043 return hostLocation;
44 }
45}