Simplify code with new Map features
[controller.git] / opendaylight / config / config-api / src / main / java / org / opendaylight / controller / config / api / ValidationException.java
index f1c90920be8c5bcaa3dbceb44226b057547560df..1d528e5b001c5c5335fff5abbba5c41e2b7ca87c 100644 (file)
@@ -43,11 +43,7 @@ public class ValidationException extends Exception {
                     String instanceName = innerEntry.getKey();
                     ExceptionMessageWithStackTrace ex = innerEntry.getValue();
                     Map<String, ExceptionMessageWithStackTrace> instanceToExMap = failedValidations
-                            .get(moduleName);
-                    if (instanceToExMap == null) {
-                        instanceToExMap = new HashMap<>();
-                        failedValidations.put(moduleName, instanceToExMap);
-                    }
+                            .computeIfAbsent(moduleName, k -> new HashMap<>());
                     if (instanceToExMap.containsKey(instanceName)) {
                         throw new IllegalArgumentException(
                                 "Cannot merge with same module name "