class ContentTypeBuilder {

    public ContentType buildContentType() {
        ContentType parsedContentType = null;
        if (StringUtils.isNotBlank(contentType)) {
            try {
                parsedContentType = ContentType.parse(contentType);
            } catch (ParseException | UnsupportedCharsetException e) {
                throw new IllegalArgumentException("Could not parse input '"
                        + HttpClientInputs.CONTENT_TYPE + "'. " + e.getMessage(), e);
            }

            if (!StringUtils.isEmpty(requestCharacterSet)) {
                try {
                    parsedContentType = parsedContentType.withCharset(requestCharacterSet);
                } catch (UnsupportedCharsetException e) {
                    throw new IllegalArgumentException("Could not parse input '" + HttpClientInputs.REQUEST_CHARACTER_SET
                            + "'. " + e.getMessage(), e);
                }
            }
        }
        return parsedContentType;
    }

}