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.service.parameters.eventprotocol;
23 import org.onap.policy.common.parameters.GroupValidationResult;
24 import org.onap.policy.common.parameters.ParameterGroup;
25 import org.onap.policy.common.parameters.ParameterRuntimeException;
26 import org.onap.policy.common.parameters.ValidationStatus;
29 * A default event protocol parameter class that may be specialized by event protocol plugins that require plugin
30 * specific parameters.
32 * <p>The following parameters are defined:
34 * <li>label: The label of the event protocol technology.
35 * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce and emit output
36 * events for this carrier technology
39 * @author Liam Fallon (liam.fallon@ericsson.com)
41 public abstract class EventProtocolParameters implements ParameterGroup {
42 // The event protocol label
43 private String label = null;
45 // Event protocol converter plugin class for this event protocol
46 private String eventProtocolPluginClass;
49 * Constructor to create an event protocol parameters instance with the name of a sub class of this class and
50 * register the instance with the parameter service.
52 * @param parameterClassName the class name of a sub class of this class
54 public EventProtocolParameters(final String parameterClassName) {
59 * Gets the label of the event protocol.
61 * @return the label of the event protocol
63 public String getLabel() {
68 * Sets the label of the event protocol.
70 * @param label the label of the event protocol
72 public void setLabel(final String label) {
73 this.label = label.replaceAll("\\s+", "");
77 * Gets the event event protocol plugin class.
79 * @return the event event protocol plugin class
81 public String getEventProtocolPluginClass() {
82 return eventProtocolPluginClass;
86 * Sets the event event protocol plugin class.
88 * @param eventProtocolPluginClass the event event protocol plugin class
90 public void setEventProtocolPluginClass(final String eventProtocolPluginClass) {
91 this.eventProtocolPluginClass = eventProtocolPluginClass.replaceAll("\\s+", "");
97 * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
100 public String toString() {
101 return "CarrierTechnologyParameters [label=" + label + ", EventProtocolPluginClass=" + eventProtocolPluginClass
108 * @see org.onap.policy.apex.service.parameters.ApexParameterValidator#validate()
111 public GroupValidationResult validate() {
112 final GroupValidationResult result = new GroupValidationResult(this);
114 if (label == null || label.length() == 0) {
115 result.setResult("label", ValidationStatus.INVALID, "event protocol label not specified or is blank");
118 if (eventProtocolPluginClass == null || eventProtocolPluginClass.length() == 0) {
119 result.setResult("eventProtocolPluginClass", ValidationStatus.INVALID,
120 "event protocol eventProtocolPluginClass not specified or is blank");
127 public String getName() {
128 return this.getLabel();
132 public void setName(final String name) {
133 throw new ParameterRuntimeException("the name/label of this event protocol is always \"" + getLabel() + "\"");