blob: e1dcf9e5c1901e676cff8b71975ec388208370df [file] [log] [blame]
tomd1900f32014-09-03 14:08:16 -07001package org.onlab.onos.net.device;
2
Yuta HIGUCHI55710e72014-10-02 14:58:32 -07003import org.onlab.onos.net.AbstractDescription;
tomca20e0c2014-09-03 23:22:24 -07004import org.onlab.onos.net.PortNumber;
Yuta HIGUCHI55710e72014-10-02 14:58:32 -07005import org.onlab.onos.net.SparseAnnotations;
tomca20e0c2014-09-03 23:22:24 -07006
tomd1900f32014-09-03 14:08:16 -07007/**
8 * Default implementation of immutable port description.
9 */
Yuta HIGUCHI55710e72014-10-02 14:58:32 -070010public class DefaultPortDescription extends AbstractDescription
11 implements PortDescription {
tomca20e0c2014-09-03 23:22:24 -070012
13 private final PortNumber number;
tomd40fc7a2014-09-04 16:41:10 -070014 private final boolean isEnabled;
tomca20e0c2014-09-03 23:22:24 -070015
Yuta HIGUCHI55710e72014-10-02 14:58:32 -070016 /**
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);
tomca20e0c2014-09-03 23:22:24 -070026 this.number = number;
tomd40fc7a2014-09-04 16:41:10 -070027 this.isEnabled = isEnabled;
tomca20e0c2014-09-03 23:22:24 -070028 }
29
Yuta HIGUCHI55710e72014-10-02 14:58:32 -070030 /**
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
tomca20e0c2014-09-03 23:22:24 -070041 @Override
42 public PortNumber portNumber() {
43 return number;
44 }
45
46 @Override
tomd40fc7a2014-09-04 16:41:10 -070047 public boolean isEnabled() {
48 return isEnabled;
tomca20e0c2014-09-03 23:22:24 -070049 }
50
Yuta HIGUCHIf1f1d322014-10-07 21:09:56 -070051 // default constructor for serialization
52 private DefaultPortDescription() {
53 this.number = null;
54 this.isEnabled = false;
55 }
tomd1900f32014-09-03 14:08:16 -070056}