64474f0e897c726b7a8b3f337d5f32b7553ba1d6
[policy/apex-pdp.git] / core / core-engine / src / main / java / org / onap / policy / apex / core / engine / TaskParameters.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.core.engine;
22
23 import lombok.Getter;
24 import lombok.Setter;
25
26 import org.onap.policy.common.parameters.BeanValidator;
27 import org.onap.policy.common.parameters.ValidationResult;
28 import org.onap.policy.common.parameters.annotations.NotBlank;
29 import org.onap.policy.common.parameters.annotations.NotNull;
30
31 /**
32  * This class provides the configurable parameters for Apex Tasks.
33  *
34  * @author Ajith Sreekumar (ajith.sreekumar@est.tech)
35  */
36 @Getter
37 @Setter
38 public class TaskParameters {
39     private String name;
40
41     // If taskId is not specified, then the taskParameter is added to all tasks in the engine.
42     private String taskId;
43
44     @NotNull
45     @NotBlank
46     private String key;
47     @NotNull
48     @NotBlank
49     private String value;
50
51     public TaskParameters() {
52         this.name = "taskParameters";
53     }
54
55     /**
56      * Full constructor.
57      *
58      * @param key the task parameter key
59      * @param value the task parameter value
60      * @param taskId the task ID of this task parameter
61      */
62     public TaskParameters(String key, String value, String taskId) {
63         this();
64         this.key = key;
65         this.value = value;
66         this.taskId = taskId;
67     }
68
69     /**
70      * Validates the parameters.
71      *
72      * @param resultName name of the result
73      *
74      * @return the validation result
75      */
76     public ValidationResult validate(String resultName) {
77         return new BeanValidator().validateTop(resultName, this);
78     }
79 }