Several fixes for Segment Routing

1. In getSubnetNextObjectiveId, do not create a broadcast group if it does not exist
       The creation is done when device is up and when config is added
2. Check if broadcast group exists before creating one
3. Put subnet in a Set instead of a List to avoid duplicated elements

Change-Id: Ifafd8e783a9d98aa62b5e299f560897458b90bb0
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
index 5c10eb6..6b51ff3 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.segmentrouting;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import org.onlab.packet.Ip4Address;
 import org.onlab.packet.Ip4Prefix;
@@ -344,12 +345,12 @@
      * @param deviceId device identifier
      * @return list of ip prefixes or null if not found
      */
-    public List<Ip4Prefix> getSubnets(DeviceId deviceId) {
+    public Set<Ip4Prefix> getSubnets(DeviceId deviceId) {
         SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId);
         if (srinfo != null) {
             log.trace("getSubnets for device{} is {}", deviceId,
                       srinfo.subnets.values());
-            return new ArrayList<>(srinfo.subnets.values());
+            return ImmutableSet.copyOf(srinfo.subnets.values());
         }
         return null;
     }
@@ -424,7 +425,7 @@
      */
     public boolean inSameSubnet(DeviceId deviceId, Ip4Address hostIp) {
 
-        List<Ip4Prefix> subnets = getSubnets(deviceId);
+        Set<Ip4Prefix> subnets = getSubnets(deviceId);
         if (subnets == null) {
             return false;
         }