aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/main/java/org/onap/policy/common/utils/validation
diff options
context:
space:
mode:
Diffstat (limited to 'utils/src/main/java/org/onap/policy/common/utils/validation')
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java11
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java10
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/validation/Version.java14
3 files changed, 15 insertions, 20 deletions
diff --git a/utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java b/utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java
index 047989e7..8e474204 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@
package org.onap.policy.common.utils.validation;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,17 +31,12 @@ import org.slf4j.LoggerFactory;
* The Class Assertions is a static class that is used as a shorthand for assertions in the source code.
* It throws runtime exceptions on assertion fails.
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class Assertions {
// Logger for this class
private static final Logger LOGGER = LoggerFactory.getLogger(Assertions.class);
/**
- * Private constructor used to prevent sub class instantiation.
- */
- private Assertions() {
- }
-
- /**
* Gets the validation message for a string parameter.
*
* @param parameterName the string parameter name
diff --git a/utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java b/utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java
index f15d936b..0723242d 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,17 +21,17 @@
package org.onap.policy.common.utils.validation;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
/**
* Class to provide utility methods for common parameter validations.
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ParameterValidationUtils {
- private ParameterValidationUtils() {
-
- }
-
/**
* Validates the given string input.
*
diff --git a/utils/src/main/java/org/onap/policy/common/utils/validation/Version.java b/utils/src/main/java/org/onap/policy/common/utils/validation/Version.java
index 41ff832a..46e006bd 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/validation/Version.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/validation/Version.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP COMMON
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,8 +21,7 @@
package org.onap.policy.common.utils.validation;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import com.google.re2j.Pattern;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
@@ -56,14 +55,13 @@ public class Version implements Comparable<Version> {
* @param versionString the version string
*/
public Version(@NonNull final String versionString) {
- Version newVersion = makeVersion("String", "constructor", versionString);
+ var newVersion = makeVersion("String", "constructor", versionString);
if (newVersion != null) {
this.major = newVersion.major;
this.minor = newVersion.minor;
this.patch = newVersion.patch;
- }
- else {
+ } else {
this.major = 0;
this.minor = 0;
this.patch = 0;
@@ -80,7 +78,7 @@ public class Version implements Comparable<Version> {
* that does not match the major.minor.patch form)
*/
public static Version makeVersion(String type, String name, String versionText) {
- Matcher matcher = VERSION_PAT.matcher(versionText);
+ var matcher = VERSION_PAT.matcher(versionText);
if (!matcher.matches()) {
logger.info("invalid version for {} {}: {}", type, name, versionText);
return null;
@@ -114,7 +112,7 @@ public class Version implements Comparable<Version> {
@Override
public int compareTo(Version other) {
- int result = Integer.compare(major, other.major);
+ var result = Integer.compare(major, other.major);
if (result != 0) {
return result;
}