Sonar Critical Fix
[dcaegen2/analytics/tca.git] / dcae-analytics-common / src / main / java / org / openecomp / dcae / apod / analytics / common / service / processor / MessageProcessor.java
1 /*\r
2  * ===============================LICENSE_START======================================\r
3  *  dcae-analytics\r
4  * ================================================================================\r
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  *  Licensed under the Apache License, Version 2.0 (the "License");\r
8  *  you may not use this file except in compliance with the License.\r
9  *   You may obtain a copy of the License at\r
10  *\r
11  *          http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  *  Unless required by applicable law or agreed to in writing, software\r
14  *  distributed under the License is distributed on an "AS IS" BASIS,\r
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  *  See the License for the specific language governing permissions and\r
17  *  limitations under the License.\r
18  *  ============================LICENSE_END===========================================\r
19  */\r
20 \r
21 package org.openecomp.dcae.apod.analytics.common.service.processor;\r
22 \r
23 import com.google.common.base.Function;\r
24 import com.google.common.base.Optional;\r
25 \r
26 import java.io.Serializable;\r
27 \r
28 /**\r
29  * <p>\r
30  *     A message processor can be used to process incoming messages.\r
31  *     It uses implementations of {@link ProcessorContext} as input and output\r
32  * </p>\r
33  *\r
34  * @param <P> Message Processor Context implementations\r
35  *\r
36  * @author Rajiv Singla . Creation Date: 11/7/2016.\r
37  */\r
38 public interface MessageProcessor<P extends ProcessorContext> extends Function<P, P>, Serializable {\r
39 \r
40     /**\r
41      * Returns processor information\r
42      *\r
43      * @return processor Information\r
44      */\r
45     ProcessorInfo getProcessorInfo();\r
46 \r
47 \r
48     /**\r
49      * Does pre-processing of {@link ProcessorContext} e.g. validate input conditions and return\r
50      * pre processed context\r
51      *\r
52      * @param processorContext incoming Processor Context\r
53      * @return Pre processed Processor Context\r
54      */\r
55     P preProcessor(P processorContext);\r
56 \r
57 \r
58     /**\r
59      * Return processing state of a processor\r
60      *\r
61      * @return Processing State\r
62      */\r
63     ProcessingState getProcessingState();\r
64 \r
65 \r
66     /**\r
67      * May return a message from a processor which indicates the reason for {@link ProcessingState} especially if\r
68      * there was some failure in processing\r
69      *\r
70      * @return processing Message\r
71      */\r
72     Optional<String> getProcessingMessage();\r
73 \r
74 \r
75     /**\r
76      * Does post-processing of {@link ProcessorContext}\r
77      *\r
78      * @param processorContext incoming Processor Context\r
79      * @return processor Context after post processing is finished\r
80      */\r
81     P postProcessor(P processorContext);\r
82 \r
83 \r
84 }\r