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.
33 * The following parameters are defined:
35 * <li>label: The label of the carrier technology.
36 * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce and emit output
37 * events for this carrier technology
38 * <li>eventConsumerPluginClass: The name of the plugin class that will be used by Apex to receive and process input
39 * events from this carrier technology carrier technology
42 * @author Liam Fallon (liam.fallon@ericsson.com)
44 public abstract class CarrierTechnologyParameters implements ParameterGroup {
46 // The carrier technology label
47 private String label = null;
49 // Producer and Consumer plugin classes for the event producer and consumer for this carrier
51 private String eventProducerPluginClass = null;
52 private String eventConsumerPluginClass = null;
55 * Constructor to create a carrier technology parameters instance with the name of a sub class of this class and
56 * register the instance with the parameter service.
58 public CarrierTechnologyParameters() {
63 * Gets the label of the carrier technology.
65 * @return the label of the carrier technology
67 public String getLabel() {
72 * Sets the label of the carrier technology.
74 * @param label the label of the carrier technology
76 public void setLabel(final String label) {
78 this.label = label.replaceAll("\\s+", "");
85 * Gets the event producer plugin class.
87 * @return the event producer plugin class
89 public String getEventProducerPluginClass() {
90 return eventProducerPluginClass;
94 * Sets the event producer plugin class.
96 * @param eventProducerPluginClass the new event producer plugin class
98 public void setEventProducerPluginClass(final String eventProducerPluginClass) {
99 if (eventProducerPluginClass != null) {
100 this.eventProducerPluginClass = eventProducerPluginClass.replaceAll("\\s+", "");
102 this.eventProducerPluginClass = null;
107 * Gets the event consumer plugin class.
109 * @return the event consumer plugin class
111 public String getEventConsumerPluginClass() {
112 return eventConsumerPluginClass;
116 * Sets the event consumer plugin class.
118 * @param eventConsumerPluginClass the new event consumer plugin class
120 public void setEventConsumerPluginClass(final String eventConsumerPluginClass) {
121 if (eventConsumerPluginClass != null) {
122 this.eventConsumerPluginClass = eventConsumerPluginClass.replaceAll("\\s+", "");
124 this.eventConsumerPluginClass = null;
131 * @see java.lang.Object#toString()
134 public String toString() {
135 return "CarrierTechnologyParameters [label=" + label + ", eventProducerPluginClass=" + eventProducerPluginClass
136 + ", eventConsumerPluginClass=" + eventConsumerPluginClass + "]";
142 * @see org.onap.policy.apex.service.parameters.ApexParameterValidator#validate()
145 public GroupValidationResult validate() {
146 final GroupValidationResult result = new GroupValidationResult(this);
148 if (label == null || label.length() == 0) {
149 result.setResult("label", ValidationStatus.INVALID, "carrier technology label not specified or is blank");
152 if (eventProducerPluginClass == null || eventProducerPluginClass.length() == 0) {
153 result.setResult("eventProducerPluginClass", ValidationStatus.INVALID,
154 "carrier technology eventProducerPluginClass not specified or is blank");
157 if (eventConsumerPluginClass == null || eventConsumerPluginClass.length() == 0) {
158 result.setResult("eventConsumerPluginClass", ValidationStatus.INVALID,
159 "carrier technology eventConsumerPluginClass not specified or is blank");
166 public String getName() {
167 return this.getLabel();
171 public void setName(final String name) {
172 throw new ParameterRuntimeException("the name/label of this carrier technology is always \"" + getLabel() + "\"");