code: public static Locale[] getLocaleList(String accept) {
          if (accept == null || accept.length() == 0) {
              return new Locale[0];
          }
  
          Map<Float, List<Locale>> locales = new TreeMap<>(new Comparator<Float>() {
              @Override
              public int compare(Float o1, Float o2) {
                  return o2.compareTo(o1);
              }
          });
          String[] segments = accept.split(",");
          for (String segment : segments) {
              Matcher matcher = LANGUAGE_SEGMENT_PATTERN.matcher(segment.trim());
              if (!matcher.matches()) {
                  continue;
              }
              float q = 1;
              if (matcher.group(5) != null) {
                  q = Float.valueOf(matcher.group(5));
              }
              List<Locale> l = locales.get(q);
              if (l == null) {
                  l = new ArrayList<>();
                  locales.put(q, l);
              }
              l.add(Locale.forLanguageTag(matcher.group(1)));
          }
  
          // Now iterates from highest q to lowest.
          List<Locale> list = new ArrayList<>();
          for (Map.Entry<Float, List<Locale>> entry : locales.entrySet()) {
              list.addAll(entry.getValue());
          }
          return list.toArray(new Locale[list.size()]);
      }
docs: Builds the list of locale in the preference order accepted by the client. For reminder,
  the ACCEPT-LANGUAGE header follows this convention:
  <code>
  <pre>
  Accept-Language = "Accept-Language" ":"
  1#( language-range [ ";" "q" "=" qvalue ] )
  language-range  = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
  </pre>
  </code>
  
  @param accept the ACCEPT-LANGUAGE header value
  @return the list of locale, empty if the header is {@literal null} or non-parseable
  @see RequestHeader#languages()