Cleanup deprecation warnings in bgp/openconfig-state
[bgpcep.git] / bgp / openconfig-state / src / main / java / org / opendaylight / protocol / bgp / state / PeerGroupUtil.java
index d66a18b79ad907fe61191620d1670cc315d144be..10ecda237c767f2406ad54a0c99b98531b5f068b 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.protocol.bgp.state;
 
+import com.google.common.collect.ImmutableMap;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
@@ -43,10 +45,11 @@ public final class PeerGroupUtil {
             return null;
         }
 
-        final List<PeerGroup> peerGroupsList = peerGroups.entrySet().stream()
-                .map(entry -> buildPeerGroupState(entry.getKey(), entry.getValue()))
-                .collect(Collectors.toList());
-        return new PeerGroupsBuilder().setPeerGroup(peerGroupsList).build();
+        return new PeerGroupsBuilder()
+                .setPeerGroup(peerGroups.entrySet().stream()
+                    .map(entry -> buildPeerGroupState(entry.getKey(), entry.getValue()))
+                    .collect(ImmutableMap.toImmutableMap(PeerGroup::key, Function.identity())))
+                .build();
     }
 
     /**
@@ -66,6 +69,6 @@ public final class PeerGroupUtil {
         return new PeerGroupBuilder()
                 .setPeerGroupName(groupId)
                 .setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group
-                        .StateBuilder().addAugmentation(PeerGroupStateAugmentation.class, groupState).build()).build();
+                        .StateBuilder().addAugmentation(groupState).build()).build();
     }
 }