37fbd32bfbe569b4f88ab260a7ce6a6e8ee94b8e
[policy/apex-pdp.git] /
1 /*-
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
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
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.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.service.parameters.eventprotocol;
22
23 import org.onap.policy.apex.service.parameters.ApexParameterValidator;
24
25 /**
26  * An event protocol parameter class for token delimited textual event protocols that may be
27  * specialized by event protocol plugins that require plugin specific parameters.
28  *
29  * <p>
30  * The following parameters are defined:
31  * <ol>
32  * <li>delimiterToken: the token string that delimits text blocks that contain events.
33  * </ol>
34  *
35  * @author Liam Fallon (liam.fallon@ericsson.com)
36  */
37 public abstract class EventProtocolTextTokenDelimitedParameters extends EventProtocolParameters
38         implements ApexParameterValidator {
39     // The delimiter token for text blocks
40     private String delimiterToken = null;
41
42     /**
43      * Constructor to create an event protocol parameters instance with the name of a sub class of
44      * this class.
45      *
46      * @param parameterClassName the class name of a sub class of this class
47      */
48     public EventProtocolTextTokenDelimitedParameters(final String parameterClassName) {
49         super(parameterClassName);
50     }
51
52     /**
53      * Gets the delimiter token that delimits events in the text.
54      *
55      * @return the delimiter token
56      */
57     public String getDelimiterToken() {
58         return delimiterToken;
59     }
60
61
62     /**
63      * Sets the delimiter token that delimits events in the text.
64      *
65      * @param delimiterToken the delimiter token
66      */
67     public void setDelimiterToken(final String delimiterToken) {
68         this.delimiterToken = delimiterToken;
69     }
70
71
72     @Override
73     public String toString() {
74         return "EventProtocolTextCharDelimitedParameters {" + super.toString() + "} [delimiterToken=" + delimiterToken
75                 + "]";
76     }
77
78     /*
79      * (non-Javadoc)
80      *
81      * @see org.onap.policy.apex.service.parameters.ApexParameterValidator#validate()
82      */
83     @Override
84     public String validate() {
85         final StringBuilder errorMessageBuilder = new StringBuilder();
86
87         errorMessageBuilder.append(super.validate());
88
89         if (delimiterToken == null || delimiterToken.length() == 0) {
90             errorMessageBuilder.append("  text delimiter token not specified or is blank\n");
91         }
92
93         return errorMessageBuilder.toString();
94     }
95 }