2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.service.parameters.carriertechnology;
24 import org.onap.policy.common.parameters.GroupValidationResult;
25 import org.onap.policy.common.parameters.ParameterGroup;
26 import org.onap.policy.common.parameters.ParameterRuntimeException;
27 import org.onap.policy.common.parameters.ValidationStatus;
30 * The default carrier technology parameter class that may be specialized by carrier technology plugins that require
31 * plugin specific parameters.
33 * <p>The following parameters are defined: <ol> <li>label: The label of the carrier technology.
34 * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce and emit output
35 * events for this carrier technology <li>eventConsumerPluginClass: The name of the plugin class that will be used by
36 * Apex to receive and process input events from this carrier technology carrier technology </ol>
38 * @author Liam Fallon (liam.fallon@ericsson.com)
40 public abstract class CarrierTechnologyParameters implements ParameterGroup {
42 // The carrier technology label
43 private String label = null;
45 // Producer and Consumer plugin classes for the event producer and consumer for this carrier
47 private String eventProducerPluginClass = null;
48 private String eventConsumerPluginClass = null;
51 * Constructor to create a carrier technology parameters instance with the name of a sub class of this class and
52 * register the instance with the parameter service.
54 protected CarrierTechnologyParameters() {
59 * Gets the label of the carrier technology.
61 * @return the label of the carrier technology
63 public String getLabel() {
68 * Sets the label of the carrier technology.
70 * @param label the label of the carrier technology
72 public void setLabel(final String label) {
74 this.label = label.replaceAll("\\s+", "");
81 * Gets the event producer plugin class.
83 * @return the event producer plugin class
85 public String getEventProducerPluginClass() {
86 return eventProducerPluginClass;
90 * Sets the event producer plugin class.
92 * @param eventProducerPluginClass the new event producer plugin class
94 public void setEventProducerPluginClass(final String eventProducerPluginClass) {
95 if (eventProducerPluginClass != null) {
96 this.eventProducerPluginClass = eventProducerPluginClass.replaceAll("\\s+", "");
98 this.eventProducerPluginClass = null;
103 * Gets the event consumer plugin class.
105 * @return the event consumer plugin class
107 public String getEventConsumerPluginClass() {
108 return eventConsumerPluginClass;
112 * Sets the event consumer plugin class.
114 * @param eventConsumerPluginClass the new event consumer plugin class
116 public void setEventConsumerPluginClass(final String eventConsumerPluginClass) {
117 if (eventConsumerPluginClass != null) {
118 this.eventConsumerPluginClass = eventConsumerPluginClass.replaceAll("\\s+", "");
120 this.eventConsumerPluginClass = null;
128 public String toString() {
129 return "CarrierTechnologyParameters [label=" + label + ", eventProducerPluginClass=" + eventProducerPluginClass
130 + ", eventConsumerPluginClass=" + eventConsumerPluginClass + "]";
137 public GroupValidationResult validate() {
138 final GroupValidationResult result = new GroupValidationResult(this);
140 if (label == null || label.length() == 0) {
141 result.setResult("label", ValidationStatus.INVALID, "carrier technology label not specified or is blank");
144 if (eventProducerPluginClass == null || eventProducerPluginClass.length() == 0) {
145 result.setResult("eventProducerPluginClass", ValidationStatus.INVALID,
146 "carrier technology eventProducerPluginClass not specified or is blank");
149 if (eventConsumerPluginClass == null || eventConsumerPluginClass.length() == 0) {
150 result.setResult("eventConsumerPluginClass", ValidationStatus.INVALID,
151 "carrier technology eventConsumerPluginClass not specified or is blank");
158 public String getName() {
159 return this.getLabel();
163 public void setName(final String name) {
164 throw new ParameterRuntimeException(
165 "the name/label of this carrier technology is always \"" + getLabel() + "\"");