code: public Optional<Charset> charset() {
      ImmutableSet<String> charsetValues = ImmutableSet.copyOf(parameters.get(CHARSET_ATTRIBUTE));
      switch (charsetValues.size()) {
        case 0:
          return Optional.absent();
        case 1:
          return Optional.of(Charset.forName(Iterables.getOnlyElement(charsetValues)));
        default:
          throw new IllegalStateException("Multiple charset values defined: " + charsetValues);
      }
    }
docs: Returns an optional charset for the value of the charset parameter if it is specified.
  
  @throws IllegalStateException if multiple charset values have been set for this media type
  @throws IllegalCharsetNameException if a charset value is present, but illegal
  @throws UnsupportedCharsetException if a charset value is present, but no support is available
  in this instance of the Java virtual machine