1fd8e7489ec856cc7fb57d9874ad759b7f4080bb
[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.eventprotocol;
23
24 import org.onap.policy.common.parameters.ParameterGroupImpl;
25 import org.onap.policy.common.parameters.ParameterRuntimeException;
26 import org.onap.policy.common.parameters.annotations.ClassName;
27 import org.onap.policy.common.parameters.annotations.NotBlank;
28 import org.onap.policy.common.parameters.annotations.NotNull;
29
30 /**
31  * A default event protocol parameter class that may be specialized by event protocol plugins that require plugin
32  * specific parameters.
33  *
34  * <p>The following parameters are defined:
35  * <ol>
36  * <li>label: The label of the event protocol 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
39  * </ol>
40  *
41  * @author Liam Fallon (liam.fallon@ericsson.com)
42  */
43 @NotNull
44 @NotBlank
45 public abstract class EventProtocolParameters extends ParameterGroupImpl {
46     // The event protocol label
47     private String label = null;
48
49     // Event protocol converter plugin class for this event protocol
50     private @ClassName String eventProtocolPluginClass;
51
52     /**
53      * Constructor to create an event protocol parameters instance with the name of a sub class of this class and
54      * register the instance with the parameter service.
55      */
56     protected EventProtocolParameters() {
57         super();
58     }
59
60     /**
61      * Gets the label of the event protocol.
62      *
63      * @return the label of the event protocol
64      */
65     public String getLabel() {
66         return label;
67     }
68
69     /**
70      * Sets the label of the event protocol.
71      *
72      * @param label the label of the event protocol
73      */
74     public void setLabel(final String label) {
75         this.label = label.replaceAll("\\s+", "");
76     }
77
78     /**
79      * Gets the event event protocol plugin class.
80      *
81      * @return the event event protocol plugin class
82      */
83     public String getEventProtocolPluginClass() {
84         return eventProtocolPluginClass;
85     }
86
87     /**
88      * Sets the event event protocol plugin class.
89      *
90      * @param eventProtocolPluginClass the event event protocol plugin class
91      */
92     public void setEventProtocolPluginClass(final String eventProtocolPluginClass) {
93         this.eventProtocolPluginClass = eventProtocolPluginClass.replaceAll("\\s+", "");
94     }
95
96     /**
97      * {@inheritDoc}.
98      */
99     @Override
100     public String toString() {
101         return "CarrierTechnologyParameters [label=" + label + ", EventProtocolPluginClass=" + eventProtocolPluginClass
102                         + "]";
103     }
104
105     @Override
106     public String getName() {
107         return this.getLabel();
108     }
109
110     @Override
111     public void setName(final String name) {
112         throw new ParameterRuntimeException("the name/label of this event protocol is always \"" + getLabel() + "\"");
113     }
114 }