mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8267587: Update java.util to use enhanced switch
Reviewed-by: iris
This commit is contained in:
parent
35916ed57f
commit
ab5a7ff230
15 changed files with 556 additions and 776 deletions
|
@ -2257,23 +2257,20 @@ public final class Locale implements Cloneable, Serializable {
|
|||
return Arrays.stream(stringList).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
switch (stringList.length) {
|
||||
case 0:
|
||||
return "";
|
||||
case 1:
|
||||
return stringList[0];
|
||||
default:
|
||||
return Arrays.stream(stringList).reduce("",
|
||||
(s1, s2) -> {
|
||||
if (s1.isEmpty()) {
|
||||
return s2;
|
||||
}
|
||||
if (s2.isEmpty()) {
|
||||
return s1;
|
||||
}
|
||||
return MessageFormat.format(pattern, s1, s2);
|
||||
});
|
||||
}
|
||||
return switch (stringList.length) {
|
||||
case 0 -> "";
|
||||
case 1 -> stringList[0];
|
||||
default -> Arrays.stream(stringList).reduce("",
|
||||
(s1, s2) -> {
|
||||
if (s1.isEmpty()) {
|
||||
return s2;
|
||||
}
|
||||
if (s2.isEmpty()) {
|
||||
return s1;
|
||||
}
|
||||
return MessageFormat.format(pattern, s1, s2);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// Duplicate of sun.util.locale.UnicodeLocaleExtension.isKey in order to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue