79ab4f7fb56707a220c24256ce2b103e084356dc
[policy/distribution.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Intel Corp. All rights reserved.
4  *  Modifications Copyright (C) 2019 AT&T Intellectual Property.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.distribution.forwarding.file;
23
24 import org.onap.policy.common.parameters.GroupValidationResult;
25 import org.onap.policy.common.parameters.ValidationStatus;
26 import org.onap.policy.common.utils.validation.ParameterValidationUtils;
27 import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup;
28
29 /**
30  * Holds the parameters for the{@link FilePolicyForwarder}.
31  */
32 public class FilePolicyForwarderParameterGroup extends PolicyForwarderConfigurationParameterGroup {
33     public static final String POLICY_FORWARDER_PLUGIN_CLASS = FilePolicyForwarder.class.getName();
34
35     private String path;
36     private boolean verbose;
37
38     /**
39      * Constructor for instantiating {@link FilePolicyForwarderParameterGroup} class.
40      *
41      * @param builder the apex forwarder parameter builder
42      */
43     public FilePolicyForwarderParameterGroup(final FilePolicyForwarderParameterBuilder builder) {
44         this.path = builder.getPath();
45         this.verbose = builder.isVerbose();
46     }
47
48     public String getPath() {
49         return path;
50     }
51
52     public boolean isVerbose() {
53         return verbose;
54     }
55
56     @Override
57     public GroupValidationResult validate() {
58         final GroupValidationResult validationResult = new GroupValidationResult(this);
59         if (!ParameterValidationUtils.validateStringParameter(path)) {
60             validationResult.setResult("path", ValidationStatus.INVALID,
61                     "must be a non-blank string containing path directory");
62         }
63         return validationResult;
64     }
65 }