blob: f5bc0d6197689921b49270b90592dfe9f3123ed8 [file] [log] [blame]
tomd1900f32014-09-03 14:08:16 -07001package org.onlab.onos.net.device;
2
tom27ae0e62014-10-01 20:35:01 -07003import org.onlab.onos.net.AbstractAnnotated;
4
tomd1900f32014-09-03 14:08:16 -07005import java.net.URI;
tom27ae0e62014-10-01 20:35:01 -07006import java.util.Map;
tomd1900f32014-09-03 14:08:16 -07007
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 */
tom27ae0e62014-10-01 20:35:01 -070015public class DefaultDeviceDescription extends AbstractAnnotated
16 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 */
tom27ae0e62014-10-01 20:35:01 -070035 @SafeVarargs
tomd1900f32014-09-03 14:08:16 -070036 public DefaultDeviceDescription(URI uri, Type type, String manufacturer,
37 String hwVersion, String swVersion,
tom27ae0e62014-10-01 20:35:01 -070038 String serialNumber,
39 Map<String, String>... annotations) {
40 super(annotations);
tomd1900f32014-09-03 14:08:16 -070041 this.uri = checkNotNull(uri, "Device URI cannot be null");
42 this.type = checkNotNull(type, "Device type cannot be null");
43 this.manufacturer = manufacturer;
44 this.hwVersion = hwVersion;
45 this.swVersion = swVersion;
46 this.serialNumber = serialNumber;
47 }
48
49 @Override
50 public URI deviceURI() {
51 return uri;
52 }
53
54 @Override
55 public Type type() {
56 return type;
57 }
58
59 @Override
60 public String manufacturer() {
61 return manufacturer;
62 }
63
64 @Override
65 public String hwVersion() {
66 return hwVersion;
67 }
68
69 @Override
70 public String swVersion() {
71 return swVersion;
72 }
73
74 @Override
75 public String serialNumber() {
76 return serialNumber;
77 }
78
79 @Override
80 public String toString() {
81 return toStringHelper(this)
82 .add("uri", uri).add("type", type).add("mfr", manufacturer)
83 .add("hw", hwVersion).add("sw", swVersion)
84 .add("serial", serialNumber)
85 .toString();
86 }
87
88}