diff options
author | 2017-11-15 15:13:59 +0530 | |
---|---|---|
committer | 2017-11-19 12:01:35 +0000 | |
commit | 581e9aa490b015d9b46314663c165a8bf12523d8 (patch) | |
tree | eaaacd22bd59163220a0e19563940a13efcc2661 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors | |
parent | b91470aaf45ccd77c56a7882f0babc9b4a2b9637 (diff) |
Adding common changes for all HEAT Validators
This commit is about adding common changes which will later be used for all validators.
Change-Id: I47cee23364c2f535482c721c25cb0038e9febc02
Issue-ID:SDC-572
Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors')
-rw-r--r-- | openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java index 5f4833a90f..0656b02089 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java @@ -21,10 +21,28 @@ package org.openecomp.core.validation.errors; +import org.openecomp.core.validation.ErrorMessageCode; + public class ErrorMessagesFormatBuilder { + private static final String messagePattern = "[%s]: %s"; + public static String getErrorWithParameters(String error, String... params) { return String.format(error, params); } + /** + * Formatted message with error code. + * + * @param messageCode error code. + * @param errorMessage error message. + * @param params parameters used in formatting message. + * @return formatted message string. + */ + public static String getErrorWithParameters(ErrorMessageCode messageCode, + String errorMessage, String... params) { + String message = getErrorWithParameters(errorMessage, params); + return ( null != messageCode && null != messageCode.getMessageCode() ) ? + String.format(messagePattern, messageCode.getMessageCode(), message) : message; + } } |