tom | d1900f3 | 2014-09-03 14:08:16 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.device; |
| 2 | |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame^] | 3 | import org.onlab.onos.net.AbstractDescription; |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 4 | import org.onlab.onos.net.PortNumber; |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame^] | 5 | import org.onlab.onos.net.SparseAnnotations; |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 6 | |
tom | d1900f3 | 2014-09-03 14:08:16 -0700 | [diff] [blame] | 7 | /** |
| 8 | * Default implementation of immutable port description. |
| 9 | */ |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame^] | 10 | public class DefaultPortDescription extends AbstractDescription |
| 11 | implements PortDescription { |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 12 | |
| 13 | private final PortNumber number; |
tom | d40fc7a | 2014-09-04 16:41:10 -0700 | [diff] [blame] | 14 | private final boolean isEnabled; |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 15 | |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame^] | 16 | /** |
| 17 | * Creates a port description using the supplied information. |
| 18 | * |
| 19 | * @param number port number |
| 20 | * @param isEnabled port enabled state |
| 21 | * @param annotations optional key/value annotations map |
| 22 | */ |
| 23 | public DefaultPortDescription(PortNumber number, boolean isEnabled, |
| 24 | SparseAnnotations... annotations) { |
| 25 | super(annotations); |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 26 | this.number = number; |
tom | d40fc7a | 2014-09-04 16:41:10 -0700 | [diff] [blame] | 27 | this.isEnabled = isEnabled; |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame^] | 30 | /** |
| 31 | * Creates a port description using the supplied information. |
| 32 | * |
| 33 | * @param base PortDescription to get basic information from |
| 34 | * @param annotations optional key/value annotations map |
| 35 | */ |
| 36 | public DefaultPortDescription(PortDescription base, |
| 37 | SparseAnnotations annotations) { |
| 38 | this(base.portNumber(), base.isEnabled(), annotations); |
| 39 | } |
| 40 | |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 41 | @Override |
| 42 | public PortNumber portNumber() { |
| 43 | return number; |
| 44 | } |
| 45 | |
| 46 | @Override |
tom | d40fc7a | 2014-09-04 16:41:10 -0700 | [diff] [blame] | 47 | public boolean isEnabled() { |
| 48 | return isEnabled; |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 49 | } |
| 50 | |
tom | d1900f3 | 2014-09-03 14:08:16 -0700 | [diff] [blame] | 51 | } |