static List<Locale> negotiatePreferredLocales(String headerValue) {

    if (headerValue == null || headerValue.isBlank()) {
      headerValue = DEFAULT_LOCALE.toLanguageTag();
    }

    try {
      var languageRanges = Locale.LanguageRange.parse(headerValue);
      return Locale.filter(languageRanges, supportedLocales);
    } catch (IllegalArgumentException e) {
      throw new ValidationException(new Message("error.unparsableHeader"));
    }
  }
@Test
  void test_negotiatePreferredLocales_validWithQualityOutOfOrder() {

    var locales = LocaleUtils.negotiatePreferredLocales("en-US;q=0.5,de-DE;q=0.8");

    // then
    assertThat(locales.get(0).getLanguage(), is("de"));
    assertThat(locales.get(1).getLanguage(), is("en"));

    // then
    assertThat(locales.size(), is(2));
  }