@UseDataProvider("forFomString") @Test public void fromString(String header, Locale expectedResult) { Locale locale = localeHeaderDelegate.fromString(header); assertEquals(expectedResult, locale); }
@Override public Locale fromString(String header) { if (header == null) { throw new IllegalArgumentException(); } header = removeWhitespaces(header); int p = scan(header, ','); if (charAtIs(header, p, ',')) { header = header.substring(0, p); } p = scan(header, '-'); if (charAtIs(header, p, '-')) { return new Locale(header.substring(0, p), header.substring(p + 1)); } return new Locale(header); }
LocaleHeaderDelegate implements RuntimeDelegate.HeaderDelegate<Locale> { @Override public Locale fromString(String header) { if (header == null) { throw new IllegalArgumentException(); } header = removeWhitespaces(header); int p = scan(header, ','); if (charAtIs(header, p, ',')) { header = header.substring(0, p); } p = scan(header, '-'); if (charAtIs(header, p, '-')) { return new Locale(header.substring(0, p), header.substring(p + 1)); } return new Locale(header); } }
LocaleHeaderDelegate implements RuntimeDelegate.HeaderDelegate<Locale> { @Override public Locale fromString(String header) { if (header == null) { throw new IllegalArgumentException(); } header = removeWhitespaces(header); int p = scan(header, ','); if (charAtIs(header, p, ',')) { header = header.substring(0, p); } p = scan(header, '-'); if (charAtIs(header, p, '-')) { return new Locale(header.substring(0, p), header.substring(p + 1)); } return new Locale(header); }  }
LocaleHeaderDelegate implements RuntimeDelegate.HeaderDelegate<Locale> { @Override public Locale fromString(String header) { if (header == null) { throw new IllegalArgumentException(); } header = removeWhitespaces(header); int p = scan(header, ','); if (charAtIs(header, p, ',')) { header = header.substring(0, p); } p = scan(header, '-'); if (charAtIs(header, p, '-')) { return new Locale(header.substring(0, p), header.substring(p + 1)); } return new Locale(header); }  @Override Locale fromString(String header); @Override String toString(Locale locale); }
LocaleHeaderDelegate implements RuntimeDelegate.HeaderDelegate<Locale> { @Override public Locale fromString(String header) { if (header == null) { throw new IllegalArgumentException(); } header = removeWhitespaces(header); int p = scan(header, ','); if (charAtIs(header, p, ',')) { header = header.substring(0, p); } p = scan(header, '-'); if (charAtIs(header, p, '-')) { return new Locale(header.substring(0, p), header.substring(p + 1)); } return new Locale(header); }  @Override Locale fromString(String header); @Override String toString(Locale locale);  }