a1dedc5c06cb9e8ed98e1a9506f360353e0027c7
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
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.apex.context.parameters;
23
24 import java.util.Map;
25 import java.util.TreeMap;
26 import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
27 import org.onap.policy.common.parameters.ParameterGroupImpl;
28 import org.onap.policy.common.parameters.annotations.NotNull;
29 import org.onap.policy.common.parameters.annotations.Valid;
30
31 /**
32  * Bean class holding schema parameters for schemas and their helpers. As more than one schema can be used in Apex
33  * simultaneously, this class is used to hold the schemas that are defined in a given Apex system and to get the schema
34  * helper plugin parameters {@link SchemaHelperParameters} for each schema.
35  *
36  * <p>The default {@code Java} schema is always defined and its parameters are held in a
37  * {@link JavaSchemaHelperParameters} instance.
38  *
39  * @author Liam Fallon (liam.fallon@ericsson.com)
40  */
41 @NotNull
42 public class SchemaParameters extends ParameterGroupImpl {
43     /** The Java schema flavour is always available for use. */
44     public static final String DEFAULT_SCHEMA_FLAVOUR = "Java";
45
46
47     // A map of parameters for executors of various logic types
48     private Map<String, @NotNull @Valid SchemaHelperParameters> schemaHelperParameterMap;
49
50     /**
51      * Constructor to create a distributor parameters instance and register the instance with the parameter service.
52      */
53     public SchemaParameters() {
54         super(ContextParameterConstants.SCHEMA_GROUP_NAME);
55
56         schemaHelperParameterMap = new TreeMap<>();
57
58         // The default schema helper
59         schemaHelperParameterMap.put(DEFAULT_SCHEMA_FLAVOUR, new JavaSchemaHelperParameters());
60     }
61
62     /**
63      * Gets a map of the schemas and schema helper parameters that are defined.
64      *
65      * @return the schema helper parameter map
66      */
67     public Map<String, SchemaHelperParameters> getSchemaHelperParameterMap() {
68         return schemaHelperParameterMap;
69     }
70
71     /**
72      * Sets the map of the schemas and schema helper parameters.
73      *
74      * @param schemaHelperParameterMap the schema helper parameter map
75      */
76     public void setSchemaHelperParameterMap(final Map<String, SchemaHelperParameters> schemaHelperParameterMap) {
77         this.schemaHelperParameterMap = schemaHelperParameterMap;
78     }
79
80     /**
81      * Gets the schema helper parameters for a given context schema flavour.
82      *
83      * @param schemaFlavour the schema flavour for which to get the schema helper parameters
84      * @return the schema helper parameters for the given schema flavour
85      */
86     public SchemaHelperParameters getSchemaHelperParameters(final String schemaFlavour) {
87         return schemaHelperParameterMap.get(schemaFlavour);
88     }
89 }