@Test public void testAccepts() { List<AcceptableLanguage> languages = AcceptableLanguage.valuesOf("da, en-gb;q=0.8, en;q=0.7"); assertThat(AcceptableLanguage.accepts(languages, new Locale("en")), is(true)); assertThat(AcceptableLanguage.accepts(languages, new Locale("da")), is(true)); assertThat(AcceptableLanguage.accepts(languages, new Locale("en", "US")), is(true)); }
public static boolean accepts(List<AcceptableLanguage> ranges, Locale candidate) { return bestCandidate(ranges, Collections.singletonList(candidate)) != null; }
AcceptableLanguage { public static boolean accepts(List<AcceptableLanguage> ranges, Locale candidate) { return bestCandidate(ranges, Collections.singletonList(candidate)) != null; } }
AcceptableLanguage { public static boolean accepts(List<AcceptableLanguage> ranges, Locale candidate) { return bestCandidate(ranges, Collections.singletonList(candidate)) != null; } private  AcceptableLanguage(String primaryTag, String subTags, double quality); }
AcceptableLanguage { public static boolean accepts(List<AcceptableLanguage> ranges, Locale candidate) { return bestCandidate(ranges, Collections.singletonList(candidate)) != null; } private  AcceptableLanguage(String primaryTag, String subTags, double quality); String getPrimaryTag(); String getSubTags(); double getQuality(); Locale asLocale(); boolean includes(Locale tag); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static List<AcceptableLanguage> valuesOf(String values); static AcceptableLanguage valueOf(String value); static Locale bestCandidate(List<AcceptableLanguage> ranges, Collection<Locale> candidates); static boolean accepts(List<AcceptableLanguage> ranges, Locale candidate); }
AcceptableLanguage { public static boolean accepts(List<AcceptableLanguage> ranges, Locale candidate) { return bestCandidate(ranges, Collections.singletonList(candidate)) != null; } private  AcceptableLanguage(String primaryTag, String subTags, double quality); String getPrimaryTag(); String getSubTags(); double getQuality(); Locale asLocale(); boolean includes(Locale tag); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static List<AcceptableLanguage> valuesOf(String values); static AcceptableLanguage valueOf(String value); static Locale bestCandidate(List<AcceptableLanguage> ranges, Collection<Locale> candidates); static boolean accepts(List<AcceptableLanguage> ranges, Locale candidate); static final AcceptableLanguage ANY; }