fe59486f3381b489c5d0d8c1117c9bb7299cc1cb
[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 lombok.AccessLevel;
25 import lombok.Getter;
26 import lombok.NoArgsConstructor;
27 import lombok.ToString;
28 import org.onap.policy.common.parameters.ParameterGroupImpl;
29 import org.onap.policy.common.parameters.ParameterRuntimeException;
30 import org.onap.policy.common.parameters.annotations.ClassName;
31 import org.onap.policy.common.parameters.annotations.NotBlank;
32 import org.onap.policy.common.parameters.annotations.NotNull;
33
34 /**
35  * A default event protocol parameter class that may be specialized by event protocol plugins that require plugin
36  * specific parameters.
37  *
38  * <p>The following parameters are defined:
39  * <ol>
40  * <li>label: The label of the event protocol technology.
41  * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce and emit output
42  * events for this carrier technology
43  * </ol>
44  *
45  * @author Liam Fallon (liam.fallon@ericsson.com)
46  */
47 @NotNull
48 @NotBlank
49 @Getter
50 @ToString
51 @NoArgsConstructor(access = AccessLevel.PROTECTED)
52 public abstract class EventProtocolParameters extends ParameterGroupImpl {
53     // The event protocol label
54     private String label = null;
55
56     // Event protocol converter plugin class for this event protocol
57     private @ClassName String eventProtocolPluginClass;
58
59     /**
60      * Sets the label of the event protocol.
61      *
62      * @param label the label of the event protocol
63      */
64     public void setLabel(final String label) {
65         this.label = label.replaceAll("\\s+", "");
66     }
67
68     /**
69      * Sets the event event protocol plugin class.
70      *
71      * @param eventProtocolPluginClass the event event protocol plugin class
72      */
73     public void setEventProtocolPluginClass(final String eventProtocolPluginClass) {
74         this.eventProtocolPluginClass = eventProtocolPluginClass.replaceAll("\\s+", "");
75     }
76
77     @Override
78     public String getName() {
79         return this.getLabel();
80     }
81
82     @Override
83     public void setName(final String name) {
84         throw new ParameterRuntimeException("the name/label of this event protocol is always \"" + getLabel() + "\"");
85     }
86 }