aboutsummaryrefslogtreecommitdiffstats
path: root/model/utilities
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-06-15 08:56:44 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-06-15 08:56:58 +0100
commit8623ca6174b6d724d3d480f0bf54300f18460350 (patch)
tree74a47f014f85709959a7683f71a19ac6fbf292c6 /model/utilities
parent4fcf04234e5e1b1d4338f12d982a45edf317d795 (diff)
Removing SONAR issues from apex-pdp basic model
Removed some code duplication in exceptions Reduced the number of unlogged exception SONAR messages to one. Issue-ID: POLICY-856 Change-Id: I19e60664270b86f77333979eaa412b2e85cb13fa Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'model/utilities')
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
index c215f3fee..80a71f8aa 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
@@ -34,6 +34,26 @@ public final class Assertions {
}
/**
+ * Gets the validation message for a string parameter.
+ *
+ * @param parameterName the string parameter name
+ * @param parameterValue the string parameter value
+ * @param pattern The regular expression
+ * @return null if the parameter is valid, the validation message otherwise
+ */
+ public static String getStringParameterValidationMessage(final String parameterName, final String parameterValue, final String pattern) {
+ try {
+ validateStringParameter(parameterName, parameterValue, pattern);
+ }
+ catch (IllegalArgumentException e) {
+ // This will cause a SONAR error but eliminates all SONAR messages in callers
+ return e.getMessage();
+ }
+
+ return null;
+ }
+
+ /**
* Checks if a string parameter matches a regular expression.
*
* @param parameterName the string parameter name