Merge "Add period after inheritDoc for Sonar"
[policy/apex-pdp.git] / services / services-engine / src / main / java / org / onap / policy / apex / service / engine / event / impl / jsonprotocolplugin / JsonEventProtocolParameters.java
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.service.engine.event.impl.jsonprotocolplugin;
22
23 import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextCharDelimitedParameters;
24
25 // @formatter:off
26 /**
27  * Event protocol parameters for JSON as an event protocol.
28  *
29  * <p>The parameters for this plugin are:
30  * <ol>
31  * <li>nameAlias: The field in a JSON event to use as an alias for the event name. This parameter is
32  * optional.
33  * <li>versionAlias: The field in a JSON event to use as an alias for the event version. This
34  * parameter is optional.
35  * <li>nameSpaceAlias: The field in a JSON event to use as an alias for the event name space. This
36  * parameter is optional.
37  * <li>sourceAlias: The field in a JSON event to use as an alias for the event source. This
38  * parameter is optional.
39  * <li>targetAlias: The field in a JSON event to use as an alias for the event target. This
40  * parameter is optional.
41  * <li>pojoField: The event is received and sent as a single POJO using the event field
42  * definition in this field name in the schema, there must be one and only one field in the
43  * event definition, the event has a single parameter whose type is the Pojo. This parameter is optional.
44  * </ol>
45  * 
46  * @author Liam Fallon (liam.fallon@ericsson.com)
47  */
48 //@formatter:on
49 public class JsonEventProtocolParameters extends EventProtocolTextCharDelimitedParameters {
50     /** The label of this event protocol. */
51     public static final String JSON_EVENT_PROTOCOL_LABEL = "JSON";
52
53     // Constants for text block delimiters
54     private static final char JSON_TEXT_BLOCK_START_DELIMITER = '{';
55     private static final char JSON_TEXT_BLOCK_END_DELIMITER = '}';
56
57     // Aliases for Apex event header fields
58     // @formatter:off
59     private String nameAlias      = null;
60     private String versionAlias   = null;
61     private String nameSpaceAlias = null;
62     private String sourceAlias    = null;
63     private String targetAlias    = null;
64     // @formatter:on
65
66     // Flag indicating POJO decoding and encoding and parameter indicating the name of the Pojo field
67     private String pojoField = null;
68
69     /**
70      * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter
71      * service.
72      */
73     public JsonEventProtocolParameters() {
74         this(JSON_EVENT_PROTOCOL_LABEL);
75     }
76
77     /**
78      * Constructor to create an event protocol parameters instance with the name of a sub class of this class.
79      * @param eventProtocolLabel the name of the event protocol for this plugin
80      */
81     public JsonEventProtocolParameters(final String eventProtocolLabel) {
82         super();
83
84         // Set the event protocol properties for the JSON event protocol
85         this.setLabel(eventProtocolLabel);
86
87         // Set the starting and ending delimiters for text blocks of JSON events
88         this.setStartChar(JSON_TEXT_BLOCK_START_DELIMITER);
89         this.setEndChar(JSON_TEXT_BLOCK_END_DELIMITER);
90
91         // Set the event protocol plugin class
92         this.setEventProtocolPluginClass(Apex2JsonEventConverter.class.getName());
93     }
94
95     /*
96      * (non-Javadoc)
97      *
98      * @see org.onap.policy.common.parameters.ParameterGroup#getName()
99      */
100     @Override
101     public String getName() {
102         return this.getLabel();
103     }
104
105     /**
106      * Gets the name alias.
107      *
108      * @return the name alias
109      */
110     public String getNameAlias() {
111         return nameAlias;
112     }
113
114     /**
115      * Gets the version alias.
116      *
117      * @return the version alias
118      */
119     public String getVersionAlias() {
120         return versionAlias;
121     }
122
123     /**
124      * Gets the name space alias.
125      *
126      * @return the name space alias
127      */
128     public String getNameSpaceAlias() {
129         return nameSpaceAlias;
130     }
131
132     /**
133      * Gets the source alias.
134      *
135      * @return the source alias
136      */
137     public String getSourceAlias() {
138         return sourceAlias;
139     }
140
141     /**
142      * Gets the target alias.
143      *
144      * @return the target alias
145      */
146     public String getTargetAlias() {
147         return targetAlias;
148     }
149
150     /**
151      * Return the name of the POJO field to use for POJO decoding and encoding.
152      * 
153      * @return the name of the POJO field
154      */
155     public String getPojoField() {
156         return pojoField;
157     }
158
159     /**
160      * Sets the name alias.
161      *
162      * @param nameAlias the new name alias
163      */
164     public void setNameAlias(String nameAlias) {
165         this.nameAlias = nameAlias;
166     }
167
168     /**
169      * Sets the version alias.
170      *
171      * @param versionAlias the new version alias
172      */
173     public void setVersionAlias(String versionAlias) {
174         this.versionAlias = versionAlias;
175     }
176
177     /**
178      * Sets the name space alias.
179      *
180      * @param nameSpaceAlias the new name space alias
181      */
182     public void setNameSpaceAlias(String nameSpaceAlias) {
183         this.nameSpaceAlias = nameSpaceAlias;
184     }
185
186     /**
187      * Sets the source alias.
188      *
189      * @param sourceAlias the new source alias
190      */
191     public void setSourceAlias(String sourceAlias) {
192         this.sourceAlias = sourceAlias;
193     }
194
195     /**
196      * Sets the target alias.
197      *
198      * @param targetAlias the new target alias
199      */
200     public void setTargetAlias(String targetAlias) {
201         this.targetAlias = targetAlias;
202     }
203
204     /**
205      * Sets the POJO field that name for POJO decoding and encoding.
206      * 
207      * @param pojoField The name of the POJO field to use on the event
208      */
209     public void setPojoField(final String pojoField) {
210         this.pojoField = pojoField;
211     }
212 }