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.carriertechnology;
23 import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
24 import org.onap.policy.apex.service.parameters.ApexParameterValidator;
27 * The default carrier technology parameter class that may be specialized by carrier technology
28 * plugins that require plugin specific parameters.
30 * The following parameters are defined:
32 * <li>label: The label of the carrier technology.
33 * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce
34 * and emit output events for this carrier technology
35 * <li>eventConsumerPluginClass: The name of the plugin class that will be used by Apex to receive
36 * and process input events from this carrier technology carrier technology
39 * @author Liam Fallon (liam.fallon@ericsson.com)
41 public abstract class CarrierTechnologyParameters extends AbstractParameters implements ApexParameterValidator {
43 // The carrier technology label
44 private String label = null;
46 // Producer and Consumer plugin classes for the event producer and consumer for this carrier
48 private String eventProducerPluginClass = null;
49 private String eventConsumerPluginClass = null;
52 * Constructor to create a carrier technology parameters instance with the name of a sub class
53 * of this class and register the instance with the parameter service.
55 * @param parameterClassName the class name of a sub class of this class
57 public CarrierTechnologyParameters(final String parameterClassName) {
58 super(parameterClassName);
62 * Gets the label of the carrier technology.
64 * @return the label of the carrier technology
66 public String getLabel() {
71 * Sets the label of the carrier technology.
73 * @param label the label of the carrier technology
75 public void setLabel(final String label) {
77 this.label = label.replaceAll("\\s+", "");
84 * Gets the event producer plugin class.
86 * @return the event producer plugin class
88 public String getEventProducerPluginClass() {
89 return eventProducerPluginClass;
93 * Sets the event producer plugin class.
95 * @param eventProducerPluginClass the new event producer plugin class
97 public void setEventProducerPluginClass(final String eventProducerPluginClass) {
98 if (eventProducerPluginClass != null) {
99 this.eventProducerPluginClass = eventProducerPluginClass.replaceAll("\\s+", "");
101 this.eventProducerPluginClass = null;
106 * Gets the event consumer plugin class.
108 * @return the event consumer plugin class
110 public String getEventConsumerPluginClass() {
111 return eventConsumerPluginClass;
115 * Sets the event consumer plugin class.
117 * @param eventConsumerPluginClass the new event consumer plugin class
119 public void setEventConsumerPluginClass(final String eventConsumerPluginClass) {
120 if (eventConsumerPluginClass != null) {
121 this.eventConsumerPluginClass = eventConsumerPluginClass.replaceAll("\\s+", "");
123 this.eventConsumerPluginClass = null;
130 * @see java.lang.Object#toString()
133 public String toString() {
134 return "CarrierTechnologyParameters [label=" + label + ", eventProducerPluginClass=" + eventProducerPluginClass
135 + ", eventConsumerPluginClass=" + eventConsumerPluginClass + "]";
141 * @see org.onap.policy.apex.service.parameters.ApexParameterValidator#validate()
144 public String validate() {
145 final StringBuilder errorMessageBuilder = new StringBuilder();
147 if (label == null || label.length() == 0) {
148 errorMessageBuilder.append(" carrier technology label not specified or is blank\n");
151 if (eventProducerPluginClass == null || eventProducerPluginClass.length() == 0) {
152 errorMessageBuilder.append(" carrier technology eventProducerPluginClass not specified or is blank\n");
155 if (eventConsumerPluginClass == null || eventConsumerPluginClass.length() == 0) {
156 errorMessageBuilder.append(" carrier technology eventConsumerPluginClass not specified or is blank\n");
159 return errorMessageBuilder.toString();