ICU-22444 Remove "unknown" from Calendar.getKeywordValuesForLocale

Remove CalType enum value UNKNOWN and use null for unknown CalType
This value is an internal enum and the only place use it is inside Calendar.java
Use null for that instead (same as C++)
This commit is contained in:
Frank Tang 2023-07-27 10:42:44 -07:00 committed by Frank Yung-Fong Tang
parent 03e98c04f3
commit 73b61ceece
3 changed files with 6 additions and 5 deletions

View file

@ -26,9 +26,7 @@ public enum CalType {
ISLAMIC_UMALQURA("islamic-umalqura"),
JAPANESE("japanese"),
PERSIAN("persian"),
ROC("roc"),
UNKNOWN("unknown");
ROC("roc");
String id;

View file

@ -1814,14 +1814,14 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
}
}
}
return CalType.UNKNOWN;
return null;
}
private static Calendar createInstance(ULocale locale) {
Calendar cal = null;
TimeZone zone = TimeZone.forULocaleOrDefault(locale);
CalType calType = getCalendarTypeForLocale(locale);
if (calType == CalType.UNKNOWN) {
if (calType == null) {
// fallback to Gregorian
calType = CalType.GREGORIAN;
}

View file

@ -2186,6 +2186,9 @@ public class CalendarRegressionTest extends com.ibm.icu.dev.test.TestFmwk {
String[] ALL = Calendar.getKeywordValuesForLocale("calendar", ULocale.getDefault(), false);
HashSet ALLSET = new HashSet();
for (int i = 0; i < ALL.length; i++) {
if (ALL[i] == "unknown") {
errln("Calendar.getKeywordValuesForLocale should not return \"unknown\"");
}
ALLSET.add(ALL[i]);
}