class LocaleHeaderDelegate implements RuntimeDelegate.HeaderDelegate<Locale> {

    @Override
    public String toString(Locale locale) {
        if (locale == null) {
            throw new IllegalArgumentException();
        }
        String language = locale.getLanguage();
        if (language.isEmpty() || "*".equals(language)) {
            return null;
        }

        String country = locale.getCountry();
        if (country.isEmpty()) {
            return language.toLowerCase();
        }

        return language.toLowerCase() + "-" + country.toLowerCase();
    }

}