Ayaka Koshibe
Committed by Gerrit Code Review

Refactoring BasicDeviceOperator:

It's no longer a subclass of BasicDeviceConfig.

Change-Id: Icb7cc7e133428a19ddd739e4135c59854b082488
...@@ -115,6 +115,16 @@ public final class AnnotationKeys { ...@@ -115,6 +115,16 @@ public final class AnnotationKeys {
115 public static final String STATIC_PORT = "staticPort"; 115 public static final String STATIC_PORT = "staticPort";
116 116
117 /** 117 /**
118 + * Annotation key for device location.
119 + */
120 + public static final String RACK_ADDRESS = "rackAddress";
121 +
122 + /**
123 + * Annotation key for device owner.
124 + */
125 + public static final String OWNER = "owner";
126 +
127 + /**
118 * Returns the value annotated object for the specified annotation key. 128 * Returns the value annotated object for the specified annotation key.
119 * The annotated value is expected to be String that can be parsed as double. 129 * The annotated value is expected to be String that can be parsed as double.
120 * If parsing fails, the returned value will be 1.0. 130 * If parsing fails, the returned value will be 1.0.
......
...@@ -30,8 +30,9 @@ import org.slf4j.Logger; ...@@ -30,8 +30,9 @@ import org.slf4j.Logger;
30 * Implementations of merge policies for various sources of device configuration 30 * Implementations of merge policies for various sources of device configuration
31 * information. This includes applications, provides, and network configurations. 31 * information. This includes applications, provides, and network configurations.
32 */ 32 */
33 -public final class BasicDeviceOperator extends BasicDeviceConfig { 33 +public final class BasicDeviceOperator {
34 34
35 + protected static final double DEFAULT_COORD = -1.0;
35 private static final Logger log = getLogger(BasicDeviceOperator.class); 36 private static final Logger log = getLogger(BasicDeviceOperator.class);
36 37
37 private BasicDeviceOperator() { 38 private BasicDeviceOperator() {
...@@ -70,7 +71,7 @@ public final class BasicDeviceOperator extends BasicDeviceConfig { ...@@ -70,7 +71,7 @@ public final class BasicDeviceOperator extends BasicDeviceConfig {
70 */ 71 */
71 public static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an) { 72 public static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an) {
72 DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); 73 DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
73 - if (bdc.driver() != an.value(DRIVER)) { 74 + if (bdc.driver() != an.value(AnnotationKeys.DRIVER)) {
74 newBuilder.set(AnnotationKeys.DRIVER, bdc.driver()); 75 newBuilder.set(AnnotationKeys.DRIVER, bdc.driver());
75 } 76 }
76 if (bdc.name() != null) { 77 if (bdc.name() != null) {
...@@ -83,10 +84,10 @@ public final class BasicDeviceOperator extends BasicDeviceConfig { ...@@ -83,10 +84,10 @@ public final class BasicDeviceOperator extends BasicDeviceConfig {
83 newBuilder.set(AnnotationKeys.LONGITUDE, Double.toString(bdc.longitude())); 84 newBuilder.set(AnnotationKeys.LONGITUDE, Double.toString(bdc.longitude()));
84 } 85 }
85 if (bdc.rackAddress() != null) { 86 if (bdc.rackAddress() != null) {
86 - newBuilder.set(RACK_ADDRESS, bdc.rackAddress()); 87 + newBuilder.set(AnnotationKeys.RACK_ADDRESS, bdc.rackAddress());
87 } 88 }
88 if (bdc.owner() != null) { 89 if (bdc.owner() != null) {
89 - newBuilder.set(OWNER, bdc.owner()); 90 + newBuilder.set(AnnotationKeys.OWNER, bdc.owner());
90 } 91 }
91 DefaultAnnotations newAnnotations = newBuilder.build(); 92 DefaultAnnotations newAnnotations = newBuilder.build();
92 return DefaultAnnotations.union(an, newAnnotations); 93 return DefaultAnnotations.union(an, newAnnotations);
......