7515de8a1cd365ceb7b6f57280f7515d94e66c10
[policy/apex-pdp.git] /
1 /*-
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.apex.service.parameters.carriertechnology;
23
24 import lombok.AccessLevel;
25 import lombok.NoArgsConstructor;
26 import org.onap.policy.common.parameters.ParameterGroupImpl;
27 import org.onap.policy.common.parameters.ParameterRuntimeException;
28 import org.onap.policy.common.parameters.annotations.ClassName;
29 import org.onap.policy.common.parameters.annotations.NotBlank;
30 import org.onap.policy.common.parameters.annotations.NotNull;
31
32 /**
33  * The default carrier technology parameter class that may be specialized by carrier technology plugins that require
34  * plugin specific parameters.
35  *
36  * <p>The following parameters are defined: <ol> <li>label: The label of the carrier technology.
37  * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce and emit output
38  * events for this carrier technology <li>eventConsumerPluginClass: The name of the plugin class that will be used by
39  * Apex to receive and process input events from this carrier technology carrier technology </ol>
40  *
41  * @author Liam Fallon (liam.fallon@ericsson.com)
42  */
43 @NotNull
44 @NotBlank
45 @NoArgsConstructor(access = AccessLevel.PROTECTED)
46 public abstract class CarrierTechnologyParameters extends ParameterGroupImpl {
47
48     // The carrier technology label
49     private String label = null;
50
51     // Producer and Consumer plugin classes for the event producer and consumer for this carrier
52     // technology
53     private @ClassName String eventProducerPluginClass = null;
54     private @ClassName String eventConsumerPluginClass = null;
55
56     /**
57      * Gets the label of the carrier technology.
58      *
59      * @return the label of the carrier technology
60      */
61     public String getLabel() {
62         return label;
63     }
64
65     /**
66      * Sets the label of the carrier technology.
67      *
68      * @param label the label of the carrier technology
69      */
70     public void setLabel(final String label) {
71         if (label != null) {
72             this.label = label.replaceAll("\\s+", "");
73         } else {
74             this.label = null;
75         }
76     }
77
78     /**
79      * Gets the event producer plugin class.
80      *
81      * @return the event producer plugin class
82      */
83     public String getEventProducerPluginClass() {
84         return eventProducerPluginClass;
85     }
86
87     /**
88      * Sets the event producer plugin class.
89      *
90      * @param eventProducerPluginClass the new event producer plugin class
91      */
92     public void setEventProducerPluginClass(final String eventProducerPluginClass) {
93         if (eventProducerPluginClass != null) {
94             this.eventProducerPluginClass = eventProducerPluginClass.replaceAll("\\s+", "");
95         } else {
96             this.eventProducerPluginClass = null;
97         }
98     }
99
100     /**
101      * Gets the event consumer plugin class.
102      *
103      * @return the event consumer plugin class
104      */
105     public String getEventConsumerPluginClass() {
106         return eventConsumerPluginClass;
107     }
108
109     /**
110      * Sets the event consumer plugin class.
111      *
112      * @param eventConsumerPluginClass the new event consumer plugin class
113      */
114     public void setEventConsumerPluginClass(final String eventConsumerPluginClass) {
115         if (eventConsumerPluginClass != null) {
116             this.eventConsumerPluginClass = eventConsumerPluginClass.replaceAll("\\s+", "");
117         } else {
118             this.eventConsumerPluginClass = null;
119         }
120     }
121
122     /**
123      * {@inheritDoc}.
124      */
125     @Override
126     public String toString() {
127         return "CarrierTechnologyParameters [label=" + label + ", eventProducerPluginClass=" + eventProducerPluginClass
128                         + ", eventConsumerPluginClass=" + eventConsumerPluginClass + "]";
129     }
130
131     @Override
132     public String getName() {
133         return this.getLabel();
134     }
135
136     @Override
137     public void setName(final String name) {
138         throw new ParameterRuntimeException(
139                         "the name/label of this carrier technology is always \"" + getLabel() + "\"");
140     }
141
142 }