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.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 * The default carrier technology parameter class that may be specialized by carrier technology plugins that require
30 * plugin specific parameters.
32 * <p>The following parameters are defined: <ol> <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 and emit output
34 * events for this carrier technology <li>eventConsumerPluginClass: The name of the plugin class that will be used by
35 * Apex to receive and process input events from this carrier technology carrier technology </ol>
37 * @author Liam Fallon (liam.fallon@ericsson.com)
39 public abstract class CarrierTechnologyParameters implements ParameterGroup {
41 // The carrier technology label
42 private String label = null;
44 // Producer and Consumer plugin classes for the event producer and consumer for this carrier
46 private String eventProducerPluginClass = null;
47 private String eventConsumerPluginClass = null;
50 * Constructor to create a carrier technology parameters instance with the name of a sub class of this class and
51 * register the instance with the parameter service.
53 public CarrierTechnologyParameters() {
58 * Gets the label of the carrier technology.
60 * @return the label of the carrier technology
62 public String getLabel() {
67 * Sets the label of the carrier technology.
69 * @param label the label of the carrier technology
71 public void setLabel(final String label) {
73 this.label = label.replaceAll("\\s+", "");
80 * Gets the event producer plugin class.
82 * @return the event producer plugin class
84 public String getEventProducerPluginClass() {
85 return eventProducerPluginClass;
89 * Sets the event producer plugin class.
91 * @param eventProducerPluginClass the new event producer plugin class
93 public void setEventProducerPluginClass(final String eventProducerPluginClass) {
94 if (eventProducerPluginClass != null) {
95 this.eventProducerPluginClass = eventProducerPluginClass.replaceAll("\\s+", "");
97 this.eventProducerPluginClass = null;
102 * Gets the event consumer plugin class.
104 * @return the event consumer plugin class
106 public String getEventConsumerPluginClass() {
107 return eventConsumerPluginClass;
111 * Sets the event consumer plugin class.
113 * @param eventConsumerPluginClass the new event consumer plugin class
115 public void setEventConsumerPluginClass(final String eventConsumerPluginClass) {
116 if (eventConsumerPluginClass != null) {
117 this.eventConsumerPluginClass = eventConsumerPluginClass.replaceAll("\\s+", "");
119 this.eventConsumerPluginClass = null;
127 public String toString() {
128 return "CarrierTechnologyParameters [label=" + label + ", eventProducerPluginClass=" + eventProducerPluginClass
129 + ", eventConsumerPluginClass=" + eventConsumerPluginClass + "]";
136 public GroupValidationResult validate() {
137 final GroupValidationResult result = new GroupValidationResult(this);
139 if (label == null || label.length() == 0) {
140 result.setResult("label", ValidationStatus.INVALID, "carrier technology label not specified or is blank");
143 if (eventProducerPluginClass == null || eventProducerPluginClass.length() == 0) {
144 result.setResult("eventProducerPluginClass", ValidationStatus.INVALID,
145 "carrier technology eventProducerPluginClass not specified or is blank");
148 if (eventConsumerPluginClass == null || eventConsumerPluginClass.length() == 0) {
149 result.setResult("eventConsumerPluginClass", ValidationStatus.INVALID,
150 "carrier technology eventConsumerPluginClass not specified or is blank");
157 public String getName() {
158 return this.getLabel();
162 public void setName(final String name) {
163 throw new ParameterRuntimeException(
164 "the name/label of this carrier technology is always \"" + getLabel() + "\"");