SonarQube says me that i need to convert this usage of the ternary operator to an "if"/"else" structure. How can i do that?
public static String transform(final List<String> list) {
return list.stream().filter(p -> p.matches(".*\\d.*"))
.reduce((a,
b) -> (Integer.parseInt(a.replaceAll("\\D+", "")) > Integer
.parseInt(b.replaceAll("\\D+", "")) ? a : b))
.orElse("there are no numbers");
}
The ternary operator is just a shortened
if/elseexpression, your code is the equivalent of: