Exemplo n.º 1
0
 /**
  * Return a string representation of the given list of {@code MediaType} objects.
  *
  * <p>This method can be used to for an {@code Accept} or {@code Content-Type} header.
  *
  * @param mediaTypes the string to parse
  * @return the list of media types
  * @throws IllegalArgumentException if the String cannot be parsed
  */
 public static String toString(Collection<MediaType> mediaTypes) {
   StringBuilder builder = new StringBuilder();
   for (Iterator<MediaType> iterator = mediaTypes.iterator(); iterator.hasNext(); ) {
     MediaType mediaType = iterator.next();
     mediaType.appendTo(builder);
     if (iterator.hasNext()) {
       builder.append(", ");
     }
   }
   return builder.toString();
 }
Exemplo n.º 2
0
 private void appendTo(StringBuilder builder) {
   builder.append(this.type);
   builder.append('/');
   builder.append(this.subtype);
   appendTo(this.parameters, builder);
 }
Exemplo n.º 3
0
 @Override
 public String toString() {
   StringBuilder builder = new StringBuilder();
   appendTo(builder);
   return builder.toString();
 }