[ONOS-8140][VOL-4152][SDFAB-94] Adding annotations to flow objectives

Change-Id: I4568b7d3bf4d5322395bbe14683ce48f93bd914e
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java
index f3d4266..37000af 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java
@@ -18,6 +18,8 @@
 import com.google.common.annotations.Beta;
 import com.google.common.collect.ImmutableList;
 import org.onosproject.core.ApplicationId;
+import org.onosproject.net.AbstractAnnotated;
+import org.onosproject.net.Annotations;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.flow.criteria.Criteria;
 import org.onosproject.net.flow.criteria.Criterion;
@@ -35,7 +37,8 @@
  * Default implementation of a filtering objective.
  */
 @Beta
-public final class DefaultFilteringObjective implements FilteringObjective {
+public final class DefaultFilteringObjective extends AbstractAnnotated
+        implements FilteringObjective {
 
     private final Type type;
     private final boolean permanent;
@@ -50,6 +53,7 @@
     private final TrafficTreatment meta;
 
     private DefaultFilteringObjective(Builder builder) {
+        super(builder.annotations);
         this.key = builder.key;
         this.type = builder.type;
         this.permanent = builder.permanent;
@@ -160,6 +164,7 @@
                 .add("appId", appId())
                 .add("permanent", permanent())
                 .add("timeout", timeout())
+                .add("annotations", annotations())
                 .toString();
     }
 
@@ -191,6 +196,7 @@
         private Operation op;
         private ObjectiveContext context;
         private TrafficTreatment meta;
+        private Annotations annotations;
 
         // Creates an empty builder
         private Builder() {
@@ -207,6 +213,7 @@
             this.appId = objective.appId();
             this.meta = objective.meta();
             this.op = objective.op();
+            this.annotations = objective.annotations();
         }
 
         @Override
@@ -265,6 +272,12 @@
         }
 
         @Override
+        public Builder withAnnotations(Annotations annotations) {
+            this.annotations = annotations;
+            return this;
+        }
+
+        @Override
         public FilteringObjective add() {
             conditions = listBuilder.build();
             op = Operation.ADD;
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
index a44b05b..bea1e96 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
@@ -18,6 +18,8 @@
 import com.google.common.annotations.Beta;
 
 import org.onosproject.core.ApplicationId;
+import org.onosproject.net.AbstractAnnotated;
+import org.onosproject.net.Annotations;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 
@@ -32,7 +34,8 @@
  * Default implementation of a forwarding objective.
  */
 @Beta
-public final class DefaultForwardingObjective implements ForwardingObjective {
+public final class DefaultForwardingObjective extends AbstractAnnotated
+        implements ForwardingObjective {
 
     private final TrafficSelector selector;
     private final Flag flag;
@@ -49,6 +52,7 @@
     private final int id;
 
     private DefaultForwardingObjective(Builder builder) {
+        super(builder.annotations);
         this.selector = builder.selector;
         this.flag = builder.flag;
         this.permanent = builder.permanent;
@@ -169,6 +173,7 @@
                 .add("appId", appId())
                 .add("permanent", permanent())
                 .add("timeout", timeout())
+                .add("annotations", annotations())
                 .toString();
     }
 
@@ -212,6 +217,8 @@
         private Operation op;
         private ObjectiveContext context;
         private TrafficSelector meta;
+        private Annotations annotations;
+
 
         // Creates an empty builder
         private Builder() {
@@ -229,6 +236,7 @@
             this.treatment = objective.treatment();
             this.op = objective.op();
             this.meta = objective.meta();
+            this.annotations = objective.annotations();
         }
 
         @Override
@@ -287,6 +295,12 @@
         }
 
         @Override
+        public Builder withAnnotations(Annotations annotations) {
+            this.annotations = annotations;
+            return this;
+        }
+
+        @Override
         public ForwardingObjective add() {
             checkNotNull(selector, "Must have a selector");
             checkNotNull(flag, "A flag must be set");
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
index 36656c4..32635cb 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
@@ -18,6 +18,8 @@
 import com.google.common.annotations.Beta;
 import com.google.common.collect.ImmutableList;
 import org.onosproject.core.ApplicationId;
+import org.onosproject.net.AbstractAnnotated;
+import org.onosproject.net.Annotations;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 
@@ -35,7 +37,8 @@
  * Default implementation of a next objective.
  */
 @Beta
-public final class DefaultNextObjective implements NextObjective {
+public final class DefaultNextObjective extends AbstractAnnotated
+        implements NextObjective {
 
     private final List<NextTreatment> treatments;
     private final ApplicationId appId;
@@ -46,6 +49,7 @@
     private final TrafficSelector meta;
 
     private DefaultNextObjective(Builder builder) {
+        super(builder.annotations);
         this.treatments = builder.treatments;
         this.appId = builder.appId;
         this.type = builder.type;
@@ -147,6 +151,7 @@
                 .add("appId", appId())
                 .add("permanent", permanent())
                 .add("timeout", timeout())
+                .add("annotations", annotations())
                 .toString();
     }
 
@@ -173,6 +178,7 @@
         private Operation op;
         private ObjectiveContext context;
         private TrafficSelector meta;
+        private Annotations annotations;
 
         private final ImmutableList.Builder<NextTreatment> listBuilder
                 = ImmutableList.builder();
@@ -190,6 +196,7 @@
             this.meta = objective.meta();
             this.appId = objective.appId();
             this.op = objective.op();
+            this.annotations = objective.annotations();
         }
 
         @Override
@@ -261,6 +268,12 @@
         }
 
         @Override
+        public Builder withAnnotations(Annotations annotations) {
+            this.annotations = annotations;
+            return this;
+        }
+
+        @Override
         public NextObjective add() {
             return add(null);
         }
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/FilteringObjective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/FilteringObjective.java
index 623de3b..641ba88 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/FilteringObjective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/FilteringObjective.java
@@ -17,6 +17,7 @@
 
 import com.google.common.annotations.Beta;
 import org.onosproject.core.ApplicationId;
+import org.onosproject.net.Annotations;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.flow.criteria.Criterion;
 
@@ -169,6 +170,16 @@
         @Override
         public Builder makePermanent();
 
+
+        /**
+         * Adds annotations to the filtering objective.
+         *
+         * @param annotations the annotations for the filtering objective
+         * @return a filtering objective builder
+         */
+         @Override
+         Builder withAnnotations(Annotations annotations);
+
         /**
          * Builds the filtering objective that will be added.
          *
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/ForwardingObjective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/ForwardingObjective.java
index a0c81af..0ae5920 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/ForwardingObjective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/ForwardingObjective.java
@@ -17,6 +17,7 @@
 
 import com.google.common.annotations.Beta;
 import org.onosproject.core.ApplicationId;
+import org.onosproject.net.Annotations;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 
@@ -182,7 +183,7 @@
         Builder withPriority(int priority);
 
         /**
-         * Makes the filtering objective permanent.
+         * Makes the forwarding objective permanent.
          *
          * @return an objective builder
          */
@@ -190,6 +191,15 @@
         Builder makePermanent();
 
         /**
+         * Adds annotations to the forwarding objective.
+         *
+         * @param annotations the annotations for the forwarding objective
+         * @return a forwarding objective builder
+         */
+        @Override
+        Builder withAnnotations(Annotations annotations);
+
+        /**
          * Builds the forwarding objective that will be added.
          *
          * @return a forwarding objective
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
index 19585f7..6d4acaa 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
@@ -17,6 +17,7 @@
 
 import com.google.common.annotations.Beta;
 import org.onosproject.core.ApplicationId;
+import org.onosproject.net.Annotations;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 
@@ -177,6 +178,15 @@
         Builder withMeta(TrafficSelector selector);
 
         /**
+         * Adds annotations to the next objective.
+         *
+         * @param annotations the annotations for the next objective
+         * @return a next objective builder
+         */
+        @Override
+        Builder withAnnotations(Annotations annotations);
+
+        /**
          * Builds the next objective that will be added.
          *
          * @return a next objective
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
index 3b0346c..8dfc176 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
@@ -17,6 +17,8 @@
 
 import com.google.common.annotations.Beta;
 import org.onosproject.core.ApplicationId;
+import org.onosproject.net.Annotated;
+import org.onosproject.net.Annotations;
 
 import java.util.Optional;
 
@@ -24,7 +26,7 @@
  * Base representation of a flow-objective description.
  */
 @Beta
-public interface Objective {
+public interface Objective extends Annotated {
 
     boolean DEFAULT_PERMANENT = true;
     int DEFAULT_TIMEOUT = 0;
@@ -174,6 +176,14 @@
         Builder withPriority(int priority);
 
         /**
+         * Adds annotations to the objective.
+         *
+         * @param annotations the annotations for the objective
+         * @return an objective builder
+         */
+         Builder withAnnotations(Annotations annotations);
+
+        /**
          * Builds the objective that will be added.
          *
          * @return an objective