Replace call to `get` with a call to `ifPresent` 73/106773/2
authorChris André <chris.andre@yoppworks.com>
Tue, 28 Apr 2020 21:49:54 +0000 (17:49 -0400)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Thu, 30 Apr 2020 14:00:50 +0000 (14:00 +0000)
Issue-ID: SDC-2989
Signed-off-by: Chris Andre <chris.andre@yoppworks.com>
Change-Id: I7fe273d869035f8852dbc398de60cc49dec2ce6e

catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java

index 14a193f..0790c4b 100644 (file)
@@ -139,10 +139,13 @@ public class CompositionBusinessLogic {
     protected void buildCirclePatternForCps(Map<ImmutablePair<Double, Double>, ComponentInstance> componentInstLocations, Map<ComponentInstance, List<ComponentInstance>> connectedCps) {
 
         for (Entry<ComponentInstance, List<ComponentInstance>> vfcCpList : connectedCps.entrySet()) {
-            Entry<ImmutablePair<Double, Double>, ComponentInstance> vfcOfTheCps = componentInstLocations.entrySet().stream().filter(p -> p.getValue().getUniqueId().equals(vfcCpList.getKey().getUniqueId())).findAny().get();
-            buildCirclePatternForOneGroupOfCps(vfcOfTheCps.getKey(), vfcCpList.getValue(), componentInstLocations);
+            componentInstLocations.entrySet().stream()
+                .filter(p -> p.getValue().getUniqueId().equals(vfcCpList.getKey().getUniqueId()))
+                .findAny()
+                .ifPresent(vfcOfTheCps ->
+                    buildCirclePatternForOneGroupOfCps(vfcOfTheCps.getKey(), vfcCpList.getValue(),
+                        componentInstLocations));
         }
-
     }
 
     private void buildCirclePatternForOneGroupOfCps(ImmutablePair<Double, Double> vfcLocation, List<ComponentInstance> cpsGroup, Map<ImmutablePair<Double, Double>, ComponentInstance> componentInstLocations) {