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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.plugins.event.protocol.yaml;
23 import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTokenDelimitedParameters;
26 * Event protocol parameters for YAML as an event protocol.
28 * <p>The parameters for this plugin are:
30 * <li>nameAlias: The field in a YAML event to use as an alias for the event name. This parameter is
32 * <li>versionAlias: The field in a YAML event to use as an alias for the event version. This
33 * parameter is optional.
34 * <li>nameSpaceAlias: The field in a YAML event to use as an alias for the event name space. This
35 * parameter is optional.
36 * <li>sourceAlias: The field in a YAML event to use as an alias for the event source. This
37 * parameter is optional.
38 * <li>targetAlias: The field in a YAML event to use as an alias for the event target. This
39 * parameter is optional.
40 * <li>yamlFieldName: The name of the field in the APEX event that will contain the unmarshaled YAML object. The
41 * parameter is optional and defaults to the value "yaml_field".
44 * @author Liam Fallon (liam.fallon@ericsson.com)
46 public class YamlEventProtocolParameters extends EventProtocolTextTokenDelimitedParameters {
47 /** The label of this event protocol. */
48 public static final String YAML_EVENT_PROTOCOL_LABEL = "YAML";
50 // Constants for text block delimiters
51 private static final String YAML_START_TEXT_DELIMITER_TOKEN = "---";
52 private static final String YAML_END_TEXT_DELIMITER_TOKEN = "...";
54 // Default parameter values
55 private static final String DEFAULT_YAML_FIELD_NAME = "yaml_field";
57 // Aliases for Apex event header fields
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 private String yamlFieldName = DEFAULT_YAML_FIELD_NAME;
68 * Constructor to create a YAML event protocol parameter instance and register the instance with
69 * the parameter service.
71 public YamlEventProtocolParameters() {
72 this(YAML_EVENT_PROTOCOL_LABEL);
76 * Constructor to create an event protocol parameters instance with the name of a sub class of
79 * @param eventProtocolLabel the name of the event protocol for this plugin
81 public YamlEventProtocolParameters(final String eventProtocolLabel) {
84 // Set the event protocol properties for the YAML event protocol
85 this.setLabel(eventProtocolLabel);
87 // Set the delimiter token for text blocks of YAML events
88 this.setStartDelimiterToken(YAML_START_TEXT_DELIMITER_TOKEN);
89 this.setEndDelimiterToken(YAML_END_TEXT_DELIMITER_TOKEN);
91 // Set the event protocol plugin class
92 this.setEventProtocolPluginClass(Apex2YamlEventConverter.class.getCanonicalName());
96 * Gets the name alias.
98 * @return the name alias
100 public String getNameAlias() {
105 * Gets the version alias.
107 * @return the version alias
109 public String getVersionAlias() {
114 * Gets the name space alias.
116 * @return the name space alias
118 public String getNameSpaceAlias() {
119 return nameSpaceAlias;
123 * Gets the source alias.
125 * @return the source alias
127 public String getSourceAlias() {
132 * Gets the target alias.
134 * @return the target alias
136 public String getTargetAlias() {
141 * Gets the YAML field name.
143 * @return the YAML field name
145 public String getYamlFieldName() {
146 return yamlFieldName;
150 * Sets the name alias.
152 * @param nameAlias the new name alias
154 public void setNameAlias(String nameAlias) {
155 this.nameAlias = nameAlias;
159 * Sets the version alias.
161 * @param versionAlias the new version alias
163 public void setVersionAlias(String versionAlias) {
164 this.versionAlias = versionAlias;
168 * Sets the name space alias.
170 * @param nameSpaceAlias the new name space alias
172 public void setNameSpaceAlias(String nameSpaceAlias) {
173 this.nameSpaceAlias = nameSpaceAlias;
177 * Sets the source alias.
179 * @param sourceAlias the new source alias
181 public void setSourceAlias(String sourceAlias) {
182 this.sourceAlias = sourceAlias;
186 * Sets the target alias.
188 * @param targetAlias the new target alias
190 public void setTargetAlias(String targetAlias) {
191 this.targetAlias = targetAlias;
195 * Sets the encapsulating object name.
197 * @param yamlFieldName
198 * the new YAML field name
200 public void setYamlFieldName(String yamlFieldName) {
201 this.yamlFieldName = yamlFieldName;