code: public static AcceptPreference fromHeaders(Collection<AcceptPreference> headers) {
          if (headers.isEmpty()) {
              throw new IllegalArgumentException("Header list must contain at least one element.");
          }
  
          TreeSet<AcceptHeaderEntry> entries = new TreeSet<>();
          for (AcceptPreference header : headers) {
              // It's OK to do this as AcceptHeaderEntry is immutable.
              entries.addAll(header.entries);
          }
  
          return new AcceptPreference(entries);
      }
docs: Constructs an {@link AcceptPreference} that is equivalent to
  the union of the <code>AcceptPreference</code>s passed as argument.
  
  @param headers a collection of accept headers that are part of single request.
  
  @return an {@link AcceptPreference} that corresponds to the merge of all headers in
  the parameter list. Example:
  
  <code>
  AcceptPreference merged = fromHeaders(fromString("text/html;q=1.0"),
  fromString("image/png;q=0.5"));
  </code>
  
  is equivalent to:
  
  <code>
  AcceptPreference merged = fromString("text/html;q=1.0,image/png;q=0.5");
  </code>