CLI command to help debug the mapping of next-Objectives to the
groups that are created by device drivers.

Change-Id: Iff9e04e5e96b2cabbdb40e83215315d2e27791a6
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/Pipeliner.java b/core/api/src/main/java/org/onosproject/net/behaviour/Pipeliner.java
index dcfc588..d1604be 100644
--- a/core/api/src/main/java/org/onosproject/net/behaviour/Pipeliner.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/Pipeliner.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.net.behaviour;
 
+import java.util.List;
+
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.driver.HandlerBehaviour;
 import org.onosproject.net.flowobjective.FilteringObjective;
@@ -54,4 +56,18 @@
      * @param nextObjective a next objectives
      */
     void next(NextObjective nextObjective);
+
+    /**
+     *  Retrieves a mapping of the nextObjective to the groups in the dataplane,
+     *  and returns it in a form that can be displayed on the CLI. Typically
+     *  group-ids are returned for groups with multiple buckets, where each list element
+     *  represents a bucket. For nextObjectives that are converted to flow-actions,
+     *  an empty list is returned.
+     *
+     *  @param nextGroup representation of the nextObjective. This representation
+     *                   is stored in the distributed group store
+     *  @return a list of preformatted strings representing group information, or
+     *          an empty list if no groups were created
+     */
+    List<String> getNextMappings(NextGroup nextGroup);
 }
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/FlowObjectiveService.java b/core/api/src/main/java/org/onosproject/net/flowobjective/FlowObjectiveService.java
index 415264e..6e905de 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/FlowObjectiveService.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/FlowObjectiveService.java
@@ -16,6 +16,9 @@
 package org.onosproject.net.flowobjective;
 
 import com.google.common.annotations.Beta;
+
+import java.util.List;
+
 import org.onosproject.net.DeviceId;
 
 /**
@@ -82,4 +85,17 @@
             throw new UnsupportedOperationException("Unsupported objective of type " + objective.getClass());
         }
     }
+
+    /**
+     * Retrieve all nextObjective to group mappings known to this onos instance,
+     * in a format meant for display on the CLI, to help with debugging. Applications
+     * are only aware of next-Ids, while the group sub-system is only aware of group-ids.
+     * This method fills in the gap by providing information on the mapping
+     * between next-ids and group-ids done by device-drivers.
+     *
+     * @return a list of strings preformatted by the device-drivers to provide
+     *         information on next-id to group-id mapping. Consumed by the
+     *         "next-ids" command on the CLI.
+     */
+    List<String> getNextMappings();
 }
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/FlowObjectiveStore.java b/core/api/src/main/java/org/onosproject/net/flowobjective/FlowObjectiveStore.java
index 85dec0f..a0a7634 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/FlowObjectiveStore.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/FlowObjectiveStore.java
@@ -16,6 +16,9 @@
 package org.onosproject.net.flowobjective;
 
 import com.google.common.annotations.Beta;
+
+import java.util.Map;
+
 import org.onosproject.net.behaviour.NextGroup;
 import org.onosproject.store.Store;
 
@@ -53,6 +56,13 @@
     NextGroup removeNextGroup(Integer nextId);
 
     /**
+     * Fetch all groups from the store and their mapping to nextIds.
+     *
+     * @return a map that represents the current snapshot of Next-ids to NextGroups
+     */
+    Map<Integer, NextGroup> getAllGroups();
+
+    /**
      * Allocates a next objective id. This id is globally unique
      *
      * @return an integer