private static void validateLocaleForFormatting()

in locales-common/src/main/java/com/spotify/i18n/locales/common/model/ResolvedLocale.java [273:293]


    private static void validateLocaleForFormatting(ResolvedLocale resolvedLocale) {
      Preconditions.checkState(
          !resolvedLocale.localeForFormatting().equals(ULocale.ROOT),
          "The given localeForFormatting cannot be the root.");

      Preconditions.checkState(
          SupportedLocale.ALL_AVAILABLE_LOCALES.contains(resolvedLocale.localeForFormatting()),
          "The given localeForFormatting %s must be canonical and available in CLDR.",
          resolvedLocale.localeForFormatting().toLanguageTag());

      ULocale rootLocaleForFormatting =
          LocalesHierarchyUtils.getHighestAncestorLocale(resolvedLocale.localeForTranslations());
      Preconditions.checkState(
          LocalesHierarchyUtils.isSameLocale(
                  resolvedLocale.localeForFormatting(), rootLocaleForFormatting)
              || LocalesHierarchyUtils.isDescendantLocale(
                  resolvedLocale.localeForFormatting(), rootLocaleForFormatting),
          "The given localeForFormatting %s is not the same as, or a descendant of the localeForTranslations %s.",
          resolvedLocale.localeForFormatting().toLanguageTag(),
          rootLocaleForFormatting.toLanguageTag());
    }