blob: fd04e5cb24d763dbe479174d970ed50d2e589f64 [file] [log] [blame]
tomd1900f32014-09-03 14:08:16 -07001package org.onlab.onos.net.device;
2
tomf5d85d42014-10-02 05:27:56 -07003import org.onlab.onos.net.AbstractDescription;
4import org.onlab.onos.net.SparseAnnotations;
tom27ae0e62014-10-01 20:35:01 -07005
tomd1900f32014-09-03 14:08:16 -07006import java.net.URI;
7
tomeadbb462014-09-07 16:10:19 -07008import static com.google.common.base.MoreObjects.toStringHelper;
tomd1900f32014-09-03 14:08:16 -07009import static com.google.common.base.Preconditions.checkNotNull;
10import static org.onlab.onos.net.Device.Type;
11
12/**
13 * Default implementation of immutable device description entity.
14 */
tomf5d85d42014-10-02 05:27:56 -070015public class DefaultDeviceDescription extends AbstractDescription
tom27ae0e62014-10-01 20:35:01 -070016 implements DeviceDescription {
tomd1900f32014-09-03 14:08:16 -070017 private final URI uri;
18 private final Type type;
19 private final String manufacturer;
20 private final String hwVersion;
21 private final String swVersion;
22 private final String serialNumber;
23
24 /**
25 * Creates a device description using the supplied information.
26 *
27 * @param uri device URI
28 * @param type device type
29 * @param manufacturer device manufacturer
30 * @param hwVersion device HW version
31 * @param swVersion device SW version
32 * @param serialNumber device serial number
tom27ae0e62014-10-01 20:35:01 -070033 * @param annotations optional key/value annotations map
tomd1900f32014-09-03 14:08:16 -070034 */
35 public DefaultDeviceDescription(URI uri, Type type, String manufacturer,
36 String hwVersion, String swVersion,
tom27ae0e62014-10-01 20:35:01 -070037 String serialNumber,
tomf5d85d42014-10-02 05:27:56 -070038 SparseAnnotations... annotations) {
tom27ae0e62014-10-01 20:35:01 -070039 super(annotations);
tomd1900f32014-09-03 14:08:16 -070040 this.uri = checkNotNull(uri, "Device URI cannot be null");
41 this.type = checkNotNull(type, "Device type cannot be null");
42 this.manufacturer = manufacturer;
43 this.hwVersion = hwVersion;
44 this.swVersion = swVersion;
45 this.serialNumber = serialNumber;
46 }
47
48 @Override
49 public URI deviceURI() {
50 return uri;
51 }
52
53 @Override
54 public Type type() {
55 return type;
56 }
57
58 @Override
59 public String manufacturer() {
60 return manufacturer;
61 }
62
63 @Override
64 public String hwVersion() {
65 return hwVersion;
66 }
67
68 @Override
69 public String swVersion() {
70 return swVersion;
71 }
72
73 @Override
74 public String serialNumber() {
75 return serialNumber;
76 }
77
78 @Override
79 public String toString() {
80 return toStringHelper(this)
81 .add("uri", uri).add("type", type).add("mfr", manufacturer)
82 .add("hw", hwVersion).add("sw", swVersion)
83 .add("serial", serialNumber)
84 .toString();
85 }
86
87}