1 /*
2  * Copyright 2002-2017 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 module hunt.stomp.converter.SmartMessageConverter;
18 
19 import hunt.stomp.converter.MessageConverter;
20 import hunt.stomp.Message;
21 import hunt.stomp.MessageHeaders;
22 
23 /**
24  * An extended {@link MessageConverter} SPI with conversion hint support.
25  *
26  * <p>In case of a conversion hint being provided, the framework will call
27  * these extended methods if a converter implements this interface, instead
28  * of calling the regular {@code fromMessage} / {@code toMessage} variants.
29  *
30  * @author Juergen Hoeller
31  * @since 4.2.1
32  */
33 interface SmartMessageConverter : MessageConverter {
34 
35 	/**
36 	 * A variant of {@link #fromMessage(Message, Class)} which takes an extra
37 	 * conversion context as an argument, allowing to take e.g. annotations
38 	 * on a payload parameter into account.
39 	 * @param message the input message
40 	 * @param targetClass the target class for the conversion
41 	 * @param conversionHint an extra object passed to the {@link MessageConverter},
42 	 * e.g. the associated {@code MethodParameter} (may be {@code null}}
43 	 * @return the result of the conversion, or {@code null} if the converter cannot
44 	 * perform the conversion
45 	 * @see #fromMessage(Message, Class)
46 	 */
47 	
48 	Object fromMessage(MessageBase message, TypeInfo targetClass, TypeInfo conversionHint);
49 
50 	alias fromMessage = MessageConverter.fromMessage;
51 
52 	/**
53 	 * A variant of {@link #toMessage(Object, MessageHeaders)} which takes an extra
54 	 * conversion context as an argument, allowing to take e.g. annotations
55 	 * on a return type into account.
56 	 * @param payload the Object to convert
57 	 * @param headers optional headers for the message (may be {@code null})
58 	 * @param conversionHint an extra object passed to the {@link MessageConverter},
59 	 * e.g. the associated {@code MethodParameter} (may be {@code null}}
60 	 * @return the new message, or {@code null} if the converter does not support the
61 	 * Object type or the target media type
62 	 * @see #toMessage(Object, MessageHeaders)
63 	 */
64 	
65 	MessageBase toMessage(Object payload, MessageHeaders headers, TypeInfo conversionHint);
66 
67 	alias toMessage = MessageConverter.toMessage;
68 
69 }