Use switch expression where feasible

This commit is contained in:
Yanming Zhou
2023-11-01 10:49:43 +08:00
committed by Sam Brannen
parent 8ed04b5dd1
commit 490b5c77fc
28 changed files with 420 additions and 424 deletions

View File

@@ -134,18 +134,14 @@ class HtmlCharacterEntityReferences {
@Nullable
public String convertToReference(char character, String encoding) {
if (encoding.startsWith("UTF-")){
switch (character){
case '<':
return "&lt;";
case '>':
return "&gt;";
case '"':
return "&quot;";
case '&':
return "&amp;";
case '\'':
return "&#39;";
}
return switch (character){
case '<' -> "&lt;";
case '>' -> "&gt;";
case '"' -> "&quot;";
case '&' -> "&amp;";
case '\'' -> "&#39;";
default -> null;
};
}
else if (character < 1000 || (character >= 8000 && character < 10000)) {
int index = (character < 1000 ? character : character - 7000);