We have a few places in our code where we check whether a value exists in a Map and then we perform some sort of operation to put the value inside that map. For example:
This can be simplified like this:
String key = entry.getKey();
String value = entry.getValue();
annotations.computeIfAbsent(key, s -> value);
According to Sonar, there are a few other places[0] across the codebase too which we can refactor to use Map.computeIfAbsent. I think we should refactor these to make use of features available by the Java 8 API.
[0] https://sonarcloud.io/organizations/jkubeio/issues?resolved=false&rules=java%3AS3824
Hi, I'd like to resolve this issue, I've created a fork in my repository, could you assign this issue to me?
Most helpful comment
Hi, I'd like to resolve this issue, I've created a fork in my repository, could you assign this issue to me?