Adding copy builders for flow objectives.

Adding missing hashCode and equals methods.

Change-Id: I97b2d904eacf0c45a95905c0891dbc6465e18ec6
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 bd58050..8010659 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
@@ -23,6 +23,7 @@
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 
 import static com.google.common.base.Preconditions.checkArgument;
@@ -102,6 +103,28 @@
         return meta;
     }
 
+    @Override
+    public int hashCode() {
+        return Objects.hash(treatments, appId, type, id, op, meta);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof DefaultNextObjective) {
+            final DefaultNextObjective other = (DefaultNextObjective) obj;
+            return Objects.equals(this.treatments, other.treatments)
+                    && Objects.equals(this.appId, other.appId)
+                    && Objects.equals(this.type, other.type)
+                    && Objects.equals(this.id, other.id)
+                    && Objects.equals(this.op, other.op)
+                    && Objects.equals(this.meta, other.meta);
+        }
+        return false;
+    }
+
     /**
      * Returns a new builder.
      *
@@ -111,6 +134,11 @@
         return new Builder();
     }
 
+    @Override
+    public Builder copy() {
+        return new Builder(this);
+    }
+
     public static final class Builder implements NextObjective.Builder {
 
         private ApplicationId appId;
@@ -124,6 +152,20 @@
         private final ImmutableList.Builder<TrafficTreatment> listBuilder
                 = ImmutableList.builder();
 
+        // Creates an empty builder
+        private Builder() {
+        }
+
+        // Creates a builder set to create a copy of the specified objective.
+        private Builder(NextObjective objective) {
+            this.type = objective.type();
+            this.id = objective.id();
+            this.treatments = ImmutableList.copyOf(objective.next());
+            this.meta = objective.meta();
+            this.appId = objective.appId();
+            this.op = objective.op();
+        }
+
         @Override
         public Builder withId(int nextId) {
             this.id = nextId;