Code example for FormHttpMessageConverter

0
 
	private final FormHttpMessageConverter delegateMessageConverter;
 
	public FormOAuth2AccessTokenMessageConverter() { 
		super(MediaType.APPLICATION_FORM_URLENCODED, MediaType.TEXT_PLAIN);
		this.delegateMessageConverter = new FormHttpMessageConverter();
	} 
 
	@Override 
	protected boolean supports(Class<?> clazz) {
		return OAuth2AccessToken.class.equals(clazz);
	} 
 
	@Override 
	protected OAuth2AccessToken readInternal(Class<? extends OAuth2AccessToken> clazz, HttpInputMessage inputMessage)
			throws IOException, HttpMessageNotReadableException {
		MultiValueMap<String, String> data = delegateMessageConverter.read(null, inputMessage);
		return DefaultOAuth2AccessToken.valueOf(data.toSingleValueMap());
	}