summaryrefslogtreecommitdiffstats
path: root/common-parameters/src
diff options
context:
space:
mode:
Diffstat (limited to 'common-parameters/src')
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java24
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java12
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java19
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java21
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java19
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java10
6 files changed, 33 insertions, 72 deletions
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java
index 240b1f40..300d49c7 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java
@@ -1,45 +1,43 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.common.parameters;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
/**
* This static class holds the values of constants for parameter handling.
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ParameterConstants {
// Indentation is 0 on the left and 2 for each level of hierarchy
public static final String DEFAULT_INITIAL_RESULT_INDENTATION = "";
public static final String DEFAULT_RESULT_INDENTATION = " ";
-
+
// By default we do not show validation results for parameters that are validated as clean
public static final boolean DO_NOT_SHOW_CLEAN_RESULTS = false;
-
+
// Messages for clean validations
public static final String PARAMETER_GROUP_HAS_STATUS_MESSAGE = "parameter group has status ";
public static final String PARAMETER_GROUP_MAP_HAS_STATUS_MESSAGE = "parameter group map has status ";
public static final String PARAMETER_HAS_STATUS_MESSAGE = "parameter has status ";
-
- /**
- * Private constructor to prevent subclassing.
- */
- private ParameterConstants() {
- // Private constructor to prevent subclassing
- }
-} \ No newline at end of file
+}
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java
index 84faa9c8..aa3105ef 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java
@@ -21,6 +21,8 @@
package org.onap.policy.common.parameters;
+import lombok.Getter;
+
/**
* Exception thrown oon parameter reading, validation, and check errors.
*
@@ -30,6 +32,7 @@ public class ParameterException extends Exception {
private static final long serialVersionUID = -8507246953751956974L;
// The object on which the exception was thrown
+ @Getter
private final transient Object object;
/**
@@ -100,13 +103,4 @@ public class ParameterException extends Exception {
return builder.toString();
}
-
- /**
- * Get the object on which the exception was thrown.
- *
- * @return The object on which the exception was thrown
- */
- public Object getObject() {
- return object;
- }
}
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java
index 071593a9..4eb79447 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java
@@ -1,25 +1,28 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.common.parameters;
+import lombok.Getter;
+
/**
* A run time exception thrown on parameter validations.
*
@@ -29,6 +32,7 @@ public class ParameterRuntimeException extends RuntimeException {
private static final long serialVersionUID = -8507246953751956974L;
// The object on which the exception was thrown
+ @Getter
private final transient Object object;
/**
@@ -81,13 +85,4 @@ public class ParameterRuntimeException extends RuntimeException {
public String getCascadedMessage() {
return ParameterException.buildCascadedMessage(this);
}
-
- /**
- * Get the object on which the exception was thrown.
- *
- * @return The object
- */
- public Object getObject() {
- return object;
- }
}
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java
index 7bf0ac5f..a368d25f 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java
@@ -25,6 +25,8 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
/**
* The parameter service makes ONAP PF parameter groups available to all classes in a JVM.
@@ -37,25 +39,18 @@ import java.util.concurrent.ConcurrentHashMap;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public abstract class ParameterService {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ParameterService {
// The map holding the parameters
private static Map<String, ParameterGroup> parameterGroupMap = new ConcurrentHashMap<>();
/**
- * This class is an abstract static class that cannot be extended.
- */
- private ParameterService() {
- }
-
- /**
* Register a parameter group with the parameter service.
*
* @param parameterGroup the parameter group
*/
public static void register(final ParameterGroup parameterGroup) {
- if (!parameterGroupMap.containsKey(parameterGroup.getName())) {
- parameterGroupMap.put(parameterGroup.getName(), parameterGroup);
- } else {
+ if (parameterGroupMap.putIfAbsent(parameterGroup.getName(), parameterGroup) != null) {
throw new ParameterRuntimeException(
"\"" + parameterGroup.getName() + "\" already registered in parameter service");
}
@@ -81,9 +76,7 @@ public abstract class ParameterService {
* @param parameterGroupName the name of the parameter group
*/
public static void deregister(final String parameterGroupName) {
- if (parameterGroupMap.containsKey(parameterGroupName)) {
- parameterGroupMap.remove(parameterGroupName);
- } else {
+ if (parameterGroupMap.remove(parameterGroupName) == null) {
throw new ParameterRuntimeException("\"" + parameterGroupName + "\" not registered in parameter service");
}
}
@@ -121,7 +114,7 @@ public abstract class ParameterService {
* @return true if the parameter is defined
*/
public static boolean contains(final String parameterGroupName) {
- return parameterGroupMap.containsKey(parameterGroupName) && parameterGroupMap.get(parameterGroupName) != null;
+ return parameterGroupMap.get(parameterGroupName) != null;
}
/**
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java
index 0fda51ad..45898818 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,12 +21,14 @@
package org.onap.policy.common.parameters;
+import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* Basic implementation of a ValidationResult.
*/
@Getter
+@AllArgsConstructor
public abstract class ValidationResultImpl implements ValidationResult {
public static final String ITEM_HAS_STATUS_MESSAGE = "item has status ";
@@ -63,21 +65,6 @@ public abstract class ValidationResultImpl implements ValidationResult {
}
/**
- * Constructs the object.
- *
- * @param name name of the object of this result
- * @param object object being validated
- * @param status the validation status
- * @param message the validation message explaining the validation status
- */
- protected ValidationResultImpl(String name, Object object, ValidationStatus status, String message) {
- this.name = name;
- this.object = object;
- this.status = status;
- this.message = message;
- }
-
- /**
* Validates that the value is not {@code null}.
*
* @return {@code true} if the value is not null, {@code false} otherwise
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java
index a8a0e614..faf41008 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
import org.onap.policy.common.parameters.annotations.NotNull;
@@ -34,6 +35,7 @@ import org.onap.policy.common.parameters.annotations.NotNull;
* Note: this currently does not support Min/Max validation of "short" or "byte"; these
* annotations are simply ignored for these types.
*/
+@NoArgsConstructor
public class ValueValidator {
/**
@@ -55,14 +57,6 @@ public class ValueValidator {
*/
protected List<Checker> checkers = new ArrayList<>(10);
-
- /**
- * Constructs the object.
- */
- public ValueValidator() {
- // do nothing
- }
-
/**
* Determines if the validator has anything to check.
*