class MediaTypeHeaderDelegate implements RuntimeDelegate.HeaderDelegate<MediaType> {

    @Override
    public String toString(MediaType mime) {
        if (mime == null) {
            throw new IllegalArgumentException();
        }
        StringBuilder sb = new StringBuilder();
        sb.append(mime.getType()).append('/').append(mime.getSubtype());

        for (Entry<String, String> entry : mime.getParameters().entrySet()) {
            sb.append(';').append(entry.getKey()).append('=');
            appendWithQuote(sb, entry.getValue());
        }

        return sb.toString();
    }

}