Fix sonar Keyword 96/106196/1
authoredyta <edyta.krukowska@nokia.com>
Fri, 17 Apr 2020 13:36:28 +0000 (15:36 +0200)
committeredyta <edyta.krukowska@nokia.com>
Fri, 17 Apr 2020 13:36:28 +0000 (15:36 +0200)
Issue-ID: INT-1517
Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com>
Change-Id: I9957d54a84a6c093e1289b66b45585a8c2b71f0e

pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/keywords/Keyword.java

index edafe8f..b7f6fb3 100644 (file)
@@ -21,10 +21,12 @@ package org.onap.pnfsimulator.simulator.keywords;
 
 import io.vavr.Function1;
 import io.vavr.Function2;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.stream.Collectors;
+
 import lombok.Getter;
 
 @Getter
@@ -34,24 +36,24 @@ public class Keyword {
     protected static final String NONLETTERS_REGEX = "([^a-zA-Z]+)";
 
     protected static final Function1<String, String> OPTIONAL =
-            (regex) -> regex + "?";
+            regex -> regex + "?";
 
     private final String name;
     private final List<String> meaningfulParts;
 
     public static final Function2<Keyword, String, Boolean> IS_MATCHING_KEYWORD_NAME = (keyword, key) ->
-        keyword != null && keyword.getName() != null && keyword.getName().equals(key);
+            keyword != null && keyword.getName() != null && keyword.getName().equals(key);
 
     /**
      * Returns list of independent parts inside the keyword. Current implementation assumes that customer can join keywords with integer values, so
      * keyword is decomposed to parts then some parts of the keyword is skipped because of replacement process.
      *
-     * @param matcher - Matcher to check find independent groups inside the keyword
+     * @param matcher    - Matcher to check find independent groups inside the keyword
      * @param skipGroups Informs this method about which groups should be consider as part of the replacement process
      * @return list of independent parts inside the keywords
      */
-    static List<String> extractPartsFrom(Matcher matcher, List skipGroups) {
-        List<String> parts = new ArrayList<String>();
+    static List<String> extractPartsFrom(Matcher matcher, List<Integer> skipGroups) {
+        List<String> parts = new ArrayList<>();
         for (int i = 1; i <= matcher.groupCount(); i++) {
             if (matcher.group(i) != null && !skipGroups.contains(i)) {
                 parts.add(matcher.group(i));
@@ -67,8 +69,8 @@ public class Keyword {
 
     public String substituteKeyword(String substitution) {
         return meaningfulParts.stream()
-            .map(part -> part.equals(name) ? substitution : part)
-            .collect(Collectors.joining());
+                .map(part -> part.equals(name) ? substitution : part)
+                .collect(Collectors.joining());
     }
 
 }