Enhanced cell & cells tools.
Provided initial sketch of the Annotated concept for the model attributes.
diff --git a/core/api/src/main/java/org/onlab/onos/net/AbstractModel.java b/core/api/src/main/java/org/onlab/onos/net/AbstractModel.java
index 8c25cda..cbafad9 100644
--- a/core/api/src/main/java/org/onlab/onos/net/AbstractModel.java
+++ b/core/api/src/main/java/org/onlab/onos/net/AbstractModel.java
@@ -1,14 +1,22 @@
package org.onlab.onos.net;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
import org.onlab.onos.net.provider.ProviderId;
+import java.util.Map;
+import java.util.Set;
+
/**
* Base implementation of a network model entity.
*/
-public class AbstractModel implements Provided {
+public class AbstractModel implements Provided, Annotated {
private final ProviderId providerId;
+ // FIXME: figure out whether to make this concurrent or immutable
+ private final Map<String, String> annotations = Maps.newHashMap();
+
// For serialization
public AbstractModel() {
providerId = null;
@@ -28,4 +36,13 @@
return providerId;
}
+ @Override
+ public Set<String> annotationKeys() {
+ return ImmutableSet.copyOf(annotations.keySet());
+ }
+
+ @Override
+ public String annotation(String key) {
+ return annotations.get(key);
+ }
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/Annotated.java b/core/api/src/main/java/org/onlab/onos/net/Annotated.java
new file mode 100644
index 0000000..f68cd46
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/Annotated.java
@@ -0,0 +1,25 @@
+package org.onlab.onos.net;
+
+import java.util.Set;
+
+/**
+ * Represents an entity that carries arbitrary annotations.
+ */
+public interface Annotated {
+
+ /**
+ * Returns the set of annotation keys currently available.
+ *
+ * @return set of annotation keys
+ */
+ Set<String> annotationKeys();
+
+ /**
+ * Returns the annotation value for the specified key.
+ *
+ * @param key annotation key
+ * @return annotation value; null if there is no annotation
+ */
+ String annotation(String key);
+
+}