X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fapi%2FValidationException.java;fp=opendaylight%2Fconfig%2Fconfig-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fapi%2FValidationException.java;h=83e83e9b176a9bb1f44c8f87535609b480e77216;hp=1d528e5b001c5c5335fff5abbba5c41e2b7ca87c;hb=c65916d075142dd937cb67e5128a87c05616b834;hpb=a7fa4e6badc5d5d3f402bedb72edebbf5c12bd2b diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java index 1d528e5b00..83e83e9b17 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -15,18 +15,22 @@ import java.util.Map; import java.util.Map.Entry; /** - * This exception is not intended to be used while implementing modules, - * it aggregates validation exceptions and sends them back to the user. - * Use {@link org.opendaylight.controller.config.api.JmxAttributeValidationException} for - * validating modules instead. + * This exception is not intended to be used while implementing modules, it + * aggregates validation exceptions and sends them back to the user. Use + * {@link org.opendaylight.controller.config.api.JmxAttributeValidationException} + * for validating modules instead. */ public class ValidationException extends Exception { private static final long serialVersionUID = -6072893219820274247L; - private final Map> failedValidations; + private final Map> failedValidations; public ValidationException( - final Map> failedValidations) { + final Map> failedValidations) { super(failedValidations.toString()); this.failedValidations = Collections.unmodifiableMap(failedValidations); } @@ -35,20 +39,17 @@ public class ValidationException extends Exception { final List collectedExceptions) { Map> failedValidations = new HashMap<>(); for (ValidationException ve : collectedExceptions) { - for (Entry> outerEntry : ve - .getFailedValidations().entrySet()) { - for (Entry innerEntry : outerEntry - .getValue().entrySet()) { + for (Entry> outerEntry : ve.getFailedValidations() + .entrySet()) { + for (Entry innerEntry : outerEntry.getValue().entrySet()) { String moduleName = outerEntry.getKey(); String instanceName = innerEntry.getKey(); ExceptionMessageWithStackTrace ex = innerEntry.getValue(); Map instanceToExMap = failedValidations .computeIfAbsent(moduleName, k -> new HashMap<>()); if (instanceToExMap.containsKey(instanceName)) { - throw new IllegalArgumentException( - "Cannot merge with same module name " - + moduleName + " and instance name " - + instanceName); + throw new IllegalArgumentException("Cannot merge with same module name " + moduleName + + " and instance name " + instanceName); } instanceToExMap.put(instanceName, ex); } @@ -57,23 +58,25 @@ public class ValidationException extends Exception { return new ValidationException(failedValidations); } - public static ValidationException createForSingleException( - final ModuleIdentifier moduleIdentifier, final Exception e) { + public static ValidationException createForSingleException(final ModuleIdentifier moduleIdentifier, + final Exception exception) { Map> failedValidations = new HashMap<>(); Map innerMap = new HashMap<>(); failedValidations.put(moduleIdentifier.getFactoryName(), innerMap); - innerMap.put(moduleIdentifier.getInstanceName(), - new ExceptionMessageWithStackTrace(e)); + innerMap.put(moduleIdentifier.getInstanceName(), new ExceptionMessageWithStackTrace(exception)); return new ValidationException(failedValidations); } - public Map> getFailedValidations() { + public Map> getFailedValidations() { return failedValidations; } public static class ExceptionMessageWithStackTrace { - private String message, stackTrace; + private String message; + private String stackTrace; public ExceptionMessageWithStackTrace() { } @@ -83,8 +86,8 @@ public class ValidationException extends Exception { this.stackTrace = stackTrace; } - public ExceptionMessageWithStackTrace(final Exception e) { - this(e.getMessage(), Arrays.toString(e.getStackTrace())); + public ExceptionMessageWithStackTrace(final Exception exception) { + this(exception.getMessage(), Arrays.toString(exception.getStackTrace())); } public String getMessage() { @@ -107,10 +110,8 @@ public class ValidationException extends Exception { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result - + ((message == null) ? 0 : message.hashCode()); - result = prime * result - + ((stackTrace == null) ? 0 : stackTrace.hashCode()); + result = prime * result + (message == null ? 0 : message.hashCode()); + result = prime * result + (stackTrace == null ? 0 : stackTrace.hashCode()); return result; } @@ -147,6 +148,5 @@ public class ValidationException extends Exception { public String toString() { return message; } - } }