code: @Override
      public Collection<MediaType> mediaTypes() {
          String contentType = request.headers().get(HeaderNames.ACCEPT);
  
          if (contentType == null) {
              // Any text by default.
              return ImmutableList.of(MediaType.ANY_TEXT_TYPE);
          }
  
          TreeSet<MediaType> set = new TreeSet<>(new Comparator<MediaType>() {
              @Override
              public int compare(MediaType o1, MediaType o2) {
                  double q1 = 1.0, q2 = 1.0;
                  List<String> ql1 = o1.parameters().get("q");
                  List<String> ql2 = o2.parameters().get("q");
  
                  if (ql1 != null && !ql1.isEmpty()) {
                      q1 = Double.parseDouble(ql1.get(0));
                  }
  
                  if (ql2 != null && !ql2.isEmpty()) {
                      q2 = Double.parseDouble(ql2.get(0));
                  }
  
                  return new Double(q2).compareTo(q1);
              }
          });
  
          // Split and sort.
          String[] segments = contentType.split(",");
          for (String segment : segments) {
              MediaType type = MediaType.parse(segment.trim());
              set.add(type);
          }
  
          return set;
      }
docs: Get the content media type that is acceptable for the client. E.g. Accept: text/*;q=0.3, text/html;q=0.7,
  text/html;level=1,text/html;level=2;q=0.4
  <p/>
  The Accept request-header field can be used to specify certain media
  types which are acceptable for the response. Accept headers can be used
  to indicate that the request is specifically limited to a small set of
  desired types, as in the case of a request for an in-line image.
  
  @return a MediaType that is acceptable for the
  client or {@see MediaType#ANY_TEXT_TYPE} if not set
  @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html"
  >http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>