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