[ONOS-5797] GroupService: add setBucketsForGroup

Add method to set all buckets from a group, overwriting the
previous group buckets entirely. Useful for edits that before
required two operations: removing the buckets and then adding
others. It can all be done with one OF message in the end.

Change-Id: Ic5669603ed4fd18b8efaa8d0253ab9d7b1e870f5
diff --git a/core/api/src/main/java/org/onosproject/net/group/GroupService.java b/core/api/src/main/java/org/onosproject/net/group/GroupService.java
index 47e0882..ef62783 100644
--- a/core/api/src/main/java/org/onosproject/net/group/GroupService.java
+++ b/core/api/src/main/java/org/onosproject/net/group/GroupService.java
@@ -107,6 +107,26 @@
                                 ApplicationId appId);
 
     /**
+     * Set buckets for an existing group. The caller can optionally
+     * associate a new cookie during this updation. GROUP_UPDATED or
+     * GROUP_UPDATE_FAILED notifications would be provided along with
+     * cookie depending on the result of the operation on the device.
+     *
+     * This operation overwrites the previous group buckets entirely.
+     *
+     * @param deviceId  device identifier
+     * @param oldCookie cookie to be used to retrieve the existing group
+     * @param buckets   immutable list of group buckets to be set
+     * @param newCookie immutable cookie to be used post update operation
+     * @param appId     Application Id
+     */
+    default void setBucketsForGroup(DeviceId deviceId,
+                                    GroupKey oldCookie,
+                                    GroupBuckets buckets,
+                                    GroupKey newCookie,
+                                    ApplicationId appId) {}
+
+    /**
      * Purges all the group entries on the specified device.
      * @param deviceId device identifier
      */
diff --git a/core/api/src/main/java/org/onosproject/net/group/GroupStore.java b/core/api/src/main/java/org/onosproject/net/group/GroupStore.java
index 0c0c06c..4559e64 100644
--- a/core/api/src/main/java/org/onosproject/net/group/GroupStore.java
+++ b/core/api/src/main/java/org/onosproject/net/group/GroupStore.java
@@ -34,7 +34,12 @@
         /**
          * Modify existing group by removing provided information from it.
          */
-        REMOVE
+        REMOVE,
+        /**
+         * Modify existing group entry by setting the provided information,
+         * overwriting the previous group entry entirely.
+         */
+        SET
     }
 
     /**