blob: 037b79666b2d86b85839cefba30a0646917c17b2 [file] [log] [blame]
tom4c6606f2014-09-07 11:11:21 -07001package org.onlab.onos.net.link;
2
alshabibdfc7afb2014-10-21 20:13:27 -07003import com.google.common.base.MoreObjects;
tomf5d85d42014-10-02 05:27:56 -07004import org.onlab.onos.net.AbstractDescription;
tom4c6606f2014-09-07 11:11:21 -07005import org.onlab.onos.net.ConnectPoint;
tomeadbb462014-09-07 16:10:19 -07006import org.onlab.onos.net.Link;
tomf5d85d42014-10-02 05:27:56 -07007import org.onlab.onos.net.SparseAnnotations;
tom4c6606f2014-09-07 11:11:21 -07008
9/**
10 * Default implementation of immutable link description entity.
11 */
tomf5d85d42014-10-02 05:27:56 -070012public class DefaultLinkDescription extends AbstractDescription
13 implements LinkDescription {
tom4c6606f2014-09-07 11:11:21 -070014
tomeadbb462014-09-07 16:10:19 -070015 private final ConnectPoint src;
16 private final ConnectPoint dst;
17 private final Link.Type type;
tom4c6606f2014-09-07 11:11:21 -070018
19 /**
20 * Creates a link description using the supplied information.
21 *
tomeadbb462014-09-07 16:10:19 -070022 * @param src link source
23 * @param dst link destination
24 * @param type link type
tomf5d85d42014-10-02 05:27:56 -070025 * @param annotations optional key/value annotations
tom4c6606f2014-09-07 11:11:21 -070026 */
tomf5d85d42014-10-02 05:27:56 -070027 public DefaultLinkDescription(ConnectPoint src, ConnectPoint dst,
28 Link.Type type, SparseAnnotations... annotations) {
29 super(annotations);
tom4c6606f2014-09-07 11:11:21 -070030 this.src = src;
31 this.dst = dst;
tomeadbb462014-09-07 16:10:19 -070032 this.type = type;
tom4c6606f2014-09-07 11:11:21 -070033 }
34
35 @Override
36 public ConnectPoint src() {
37 return src;
38 }
39
40 @Override
41 public ConnectPoint dst() {
42 return dst;
43 }
44
tomeadbb462014-09-07 16:10:19 -070045 @Override
46 public Link.Type type() {
tomd176fc42014-09-08 00:12:30 -070047 return type;
tomeadbb462014-09-07 16:10:19 -070048 }
49
alshabibdfc7afb2014-10-21 20:13:27 -070050 @Override
51 public String toString() {
52 return MoreObjects.toStringHelper("Link").add("src", src())
53 .add("dst", dst())
54 .add("type", type()).toString();
55 }
56
tom4c6606f2014-09-07 11:11:21 -070057}