tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.link; |
| 2 | |
alshabib | dfc7afb | 2014-10-21 20:13:27 -0700 | [diff] [blame] | 3 | import com.google.common.base.MoreObjects; |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 4 | import org.onlab.onos.net.AbstractDescription; |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 5 | import org.onlab.onos.net.ConnectPoint; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 6 | import org.onlab.onos.net.Link; |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 7 | import org.onlab.onos.net.SparseAnnotations; |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 8 | |
| 9 | /** |
| 10 | * Default implementation of immutable link description entity. |
| 11 | */ |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 12 | public class DefaultLinkDescription extends AbstractDescription |
| 13 | implements LinkDescription { |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 14 | |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 15 | private final ConnectPoint src; |
| 16 | private final ConnectPoint dst; |
| 17 | private final Link.Type type; |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Creates a link description using the supplied information. |
| 21 | * |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 22 | * @param src link source |
| 23 | * @param dst link destination |
| 24 | * @param type link type |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 25 | * @param annotations optional key/value annotations |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 26 | */ |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 27 | public DefaultLinkDescription(ConnectPoint src, ConnectPoint dst, |
| 28 | Link.Type type, SparseAnnotations... annotations) { |
| 29 | super(annotations); |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 30 | this.src = src; |
| 31 | this.dst = dst; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 32 | this.type = type; |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public ConnectPoint src() { |
| 37 | return src; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public ConnectPoint dst() { |
| 42 | return dst; |
| 43 | } |
| 44 | |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 45 | @Override |
| 46 | public Link.Type type() { |
tom | d176fc4 | 2014-09-08 00:12:30 -0700 | [diff] [blame] | 47 | return type; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 48 | } |
| 49 | |
alshabib | dfc7afb | 2014-10-21 20:13:27 -0700 | [diff] [blame] | 50 | @Override |
| 51 | public String toString() { |
| 52 | return MoreObjects.toStringHelper("Link").add("src", src()) |
| 53 | .add("dst", dst()) |
| 54 | .add("type", type()).toString(); |
| 55 | } |
| 56 | |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 57 | } |