80ec0eb2d9ce74065de9d50efe29d52787041a27
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
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.context.parameters;
22
23 import org.onap.policy.common.parameters.GroupValidationResult;
24 import org.onap.policy.common.parameters.ParameterGroup;
25
26 /**
27  * Bean class to hold parameters for context handling in Apex. This class contains all the context
28  * parameters for schema handling, distribution, locking, and persistence of context albums.
29  *
30  * <p>The following parameters are defined:
31  * <ol>
32  * <li>flushPeriod: Context is flushed to any persistor plugin that is defined periodically, and the
33  * period for flushing is the flush period.
34  * <li>distributorParameters: The parameters (a {@link DistributorParameters} instance) for the
35  * distributor plugin that is being used for context album distribution
36  * <li>schemaParameters: The parameters (a {@link SchemaParameters} instance) for the schema plugin
37  * that is being used for context album schemas
38  * <li>lockManagerParameters: The parameters (a {@link LockManagerParameters} instance) for the
39  * locking mechanism plugin that is being used for context album locking
40  * <li>persistorParameters: The parameters (a {@link PersistorParameters} instance) for the
41  * persistence plugin that is being used for context album persistence
42  * </ol>
43  *
44  * @author Liam Fallon (liam.fallon@ericsson.com)
45  */
46 public class ContextParameters implements ParameterGroup {
47     // @formatter:off
48     // Plugin Parameters
49     private String                name;
50     private DistributorParameters distributorParameters = new DistributorParameters();
51     private SchemaParameters      schemaParameters      = new SchemaParameters();
52     private LockManagerParameters lockManagerParameters = new LockManagerParameters();
53     private PersistorParameters   persistorParameters   = new PersistorParameters();
54     // @formatter:on
55
56     /**
57      * Constructor to create a context parameters instance and register the instance with the
58      * parameter service.
59      */
60     public ContextParameters() {
61         super();
62
63         // Set the name for the parameters
64         this.name = ContextParameterConstants.MAIN_GROUP_NAME;
65     }
66
67     /**
68      * Gets the distributor parameters.
69      *
70      * @return the distributor parameters
71      */
72     public DistributorParameters getDistributorParameters() {
73         return distributorParameters;
74     }
75
76     /**
77      * Sets the distributor parameters.
78      *
79      * @param distributorParameters the distributor parameters
80      */
81     public void setDistributorParameters(final DistributorParameters distributorParameters) {
82         this.distributorParameters = distributorParameters;
83     }
84
85     /**
86      * Gets the schema parameters.
87      *
88      * @return the schema parameters
89      */
90     public SchemaParameters getSchemaParameters() {
91         return schemaParameters;
92     }
93
94     /**
95      * Sets the schema parameters.
96      *
97      * @param schemaParameters the schema parameters
98      */
99     public void setSchemaParameters(final SchemaParameters schemaParameters) {
100         this.schemaParameters = schemaParameters;
101     }
102
103     /**
104      * Gets the lock manager parameters.
105      *
106      * @return the lock manager parameters
107      */
108     public LockManagerParameters getLockManagerParameters() {
109         return lockManagerParameters;
110     }
111
112     /**
113      * Sets the lock manager parameters.
114      *
115      * @param lockManagerParameters the lock manager parameters
116      */
117     public void setLockManagerParameters(final LockManagerParameters lockManagerParameters) {
118         this.lockManagerParameters = lockManagerParameters;
119     }
120
121     /**
122      * Gets the persistor parameters.
123      *
124      * @return the persistor parameters
125      */
126     public PersistorParameters getPersistorParameters() {
127         return persistorParameters;
128     }
129
130     /**
131      * Sets the persistor parameters.
132      *
133      * @param persistorParameters the persistor parameters
134      */
135     public void setPersistorParameters(final PersistorParameters persistorParameters) {
136         this.persistorParameters = persistorParameters;
137     }
138     
139     @Override
140     public String toString() {
141         return "ContextParameters [name=" + name + ", distributorParameters=" + distributorParameters
142                         + ", schemaParameters=" + schemaParameters + ", lockManagerParameters=" + lockManagerParameters
143                         + ", persistorParameters=" + persistorParameters + "]";
144     }
145
146     @Override
147     public String getName() {
148         return name;
149     }
150
151     @Override
152     public void setName(final String name) {
153         this.name = name;
154     }
155
156     @Override
157     public GroupValidationResult validate() {
158         return new GroupValidationResult(this);
159     }
160 }