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.GenericMessageConverter;
18 
19 import hunt.stomp.converter.AbstractMessageConverter;
20 
21 // import hunt.framework.core.convert.ConversionException;
22 // import hunt.framework.core.convert.ConversionService;
23 // import hunt.framework.core.convert.support.DefaultConversionService;
24 
25 import hunt.stomp.Message;
26 
27 // import hunt.framework.util.ClassUtils;
28 
29 /**
30  * An extension of the {@link SimpleMessageConverter} that uses a
31  * {@link ConversionService} to convert the payload of the message
32  * to the requested type.
33  *
34  * <p>Return {@code null} if the conversion service cannot convert
35  * from the payload type to the requested type.
36  *
37  * @author Stephane Nicoll
38  * @since 4.1
39  * @see ConversionService
40  */
41 // class GenericMessageConverter : SimpleMessageConverter {
42 
43 // 	private final ConversionService conversionService;
44 
45 
46 // 	/**
47 // 	 * Create a new instance with a default {@link ConversionService}.
48 // 	 */
49 // 	this() {
50 // 		this.conversionService = DefaultConversionService.getSharedInstance();
51 // 	}
52 
53 // 	/**
54 // 	 * Create a new instance with the given {@link ConversionService}.
55 // 	 */
56 // 	this(ConversionService conversionService) {
57 // 		assert(conversionService, "ConversionService must not be null");
58 // 		this.conversionService = conversionService;
59 // 	}
60 
61 
62 // 	override
63 	
64 // 	Object fromMessage(MessageBase message, Class<?> targetClass) {
65 // 		Object payload = message.getPayload();
66 // 		if (this.conversionService.canConvert(payload.getClass(), targetClass)) {
67 // 			try {
68 // 				return this.conversionService.convert(payload, targetClass);
69 // 			}
70 // 			catch (ConversionException ex) {
71 // 				throw new MessageConversionException(message, "Failed to convert message payload '" ~
72 // 						payload ~ "' to '" ~ targetClass.getName() ~ "'", ex);
73 // 			}
74 // 		}
75 // 		return (ClassUtils.isAssignableValue(targetClass, payload) ? payload : null);
76 // 	}
77 
78 // }