class MultivaluedMapEntityProvider implements EntityProvider<MultivaluedMap<String, String>> {

    @Override
    @SuppressWarnings("unchecked")
    public MultivaluedMap<String, String> readFrom(Class<MultivaluedMap<String, String>> type,
                                                   Type genericType,
                                                   Annotation[] annotations,
                                                   MediaType mediaType,
                                                   MultivaluedMap<String, String> httpHeaders,
                                                   InputStream entityStream) throws IOException {
        ApplicationContext context = ApplicationContext.getCurrent();
        Object decodedMap = context.getAttributes().get("org.everrest.provider.entity.decoded.form");
        if (decodedMap != null) {
            return (MultivaluedMap<String, String>)decodedMap;
        }

        MultivaluedMap<String, String> encodedForm = new MultivaluedMapImpl();
        MultivaluedMap<String, String> decodedForm = new MultivaluedMapImpl();
        StringBuilder sb = new StringBuilder();
        int r;
        while ((r = entityStream.read()) != -1) {
            if (r != '&') {
                sb.append((char)r);
            } else {
                parseKeyValuePair(sb.toString().trim(), encodedForm, decodedForm);
                sb.setLength(0);
            }
        }
        parseKeyValuePair(sb.toString().trim(), encodedForm, decodedForm);

        if (decodedForm.isEmpty() && httpRequest != null) {
            httpRequest.getParameterMap()
                       .entrySet()
                       .stream()
                       .filter(e -> e.getValue() != null)
                       .forEach(e -> decodedForm.addAll(e.getKey(), e.getValue()));
        }

        context.getAttributes().put("org.everrest.provider.entity.decoded.form", decodedForm);
        context.getAttributes().put("org.everrest.provider.entity.encoded.form", encodedForm);

        return decodedForm;
    }

    public  MultivaluedMapEntityProvider(@Context HttpServletRequest httpRequest);

}