HttpMessageConverter for Single Object and List of Object
Does it work if you try adding the following method to your (single-property) converter?
@Override
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) {
return super.canWrite(clazz, mediaType) && clazz == Property.class;
}
The AbstractMessageConverterMethodProcessor
class loops through all registered converters and skips any for which the canWrite
method returns false
. I've adapted the method above from the AbstractGenericHttpMessageConverter
class, adding an extra check on the class of the value to be written, so that it should only be used to write out Property
values.
Note that the single-property converter should be added to the list of converters before the multi-property converter. Alternatively, make a similar modification to your multi-property converter too.