Change return type of groupId() in FlowRule not to misusing underlying type

Change-Id: Ide90973380f79046650bc372b9ecee00cb290f6a
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
index deef14e..4bbcca1 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
@@ -21,6 +21,8 @@
 import java.util.Objects;
 
 import org.onlab.onos.core.ApplicationId;
+import org.onlab.onos.core.DefaultGroupId;
+import org.onlab.onos.core.GroupId;
 import org.onlab.onos.net.DeviceId;
 import org.slf4j.Logger;
 
@@ -40,7 +42,7 @@
 
     private final int timeout;
     private final boolean permanent;
-    private final short groupId;
+    private final GroupId groupId;
 
 
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
@@ -55,19 +57,26 @@
         this.created = System.currentTimeMillis();
 
         this.appId = (short) (flowId >>> 48);
-        this.groupId = (short) ((flowId >>> 32) & 0xFFFF);
+        this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
         this.id = FlowId.valueOf(flowId);
     }
 
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
                            TrafficTreatment treatment, int priority, ApplicationId appId,
                            int timeout, boolean permanent) {
-        this(deviceId, selector, treatment, priority, appId, (short) 0, timeout, permanent);
+        this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(0), timeout, permanent);
+    }
+
+    @Deprecated
+    public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
+                           TrafficTreatment treatment, int priority, ApplicationId appId,
+                           short groupId, int timeout, boolean permanent) {
+        this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(groupId), timeout, permanent);
     }
 
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
                            TrafficTreatment treatment, int priority, ApplicationId appId,
-                           short groupId, int timeout, boolean permanent) {
+                           GroupId groupId, int timeout, boolean permanent) {
 
         if (priority < FlowRule.MIN_PRIORITY) {
             throw new IllegalArgumentException("Priority cannot be less than " + MIN_PRIORITY);
@@ -87,8 +96,8 @@
          * id consists of the following.
          * | appId (16 bits) | groupId (16 bits) | flowId (32 bits) |
          */
-        this.id = FlowId.valueOf((((long) this.appId) << 48) | (((long) this.groupId) << 32)
-                                         | (this.hash() & 0xffffffffL));
+        this.id = FlowId.valueOf((((long) this.appId) << 48) | (((long) this.groupId.id()) << 32)
+                | (this.hash() & 0xffffffffL));
     }
 
     public DefaultFlowRule(FlowRule rule) {
@@ -117,7 +126,7 @@
     }
 
     @Override
-    public short groupId() {
+    public GroupId groupId() {
         return groupId;
     }