diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index e57c9dd8bc2..6905dd174a1 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -8,6 +8,11 @@ + + + + + diff --git a/src/main/java/org/jabref/logic/layout/format/AuthorAndsReplacer.java b/src/main/java/org/jabref/logic/layout/format/AuthorAndsReplacer.java index bf4be2b51f4..52531b47466 100644 --- a/src/main/java/org/jabref/logic/layout/format/AuthorAndsReplacer.java +++ b/src/main/java/org/jabref/logic/layout/format/AuthorAndsReplacer.java @@ -18,28 +18,22 @@ public String format(String fieldText) { return null; } String[] authors = fieldText.split(" and "); - String s; - - switch (authors.length) { - case 1: - //Does nothing; - s = authors[0]; - break; - case 2: - s = authors[0] + " & " + authors[1]; - break; - default: - int i; - int x = authors.length; - StringBuilder sb = new StringBuilder(); - - for (i = 0; i < (x - 2); i++) { - sb.append(authors[i]).append("; "); + //CHECKSTYLE:OFF + String s = switch (authors.length) { + case 1 -> authors[0]; // just no action + case 2 -> authors[0] + " & " + authors[1]; + default -> { + int i; + int x = authors.length; + StringBuilder sb = new StringBuilder(); + for (i = 0; i < (x - 2); i++) { + sb.append(authors[i]).append("; "); + } + sb.append(authors[i]).append(" & ").append(authors[i + 1]); + yield sb.toString(); } - sb.append(authors[i]).append(" & ").append(authors[i + 1]); - s = sb.toString(); - break; - } + }; + //CHECKSTYLE:ON return s; diff --git a/src/main/java/org/jabref/logic/layout/format/Ordinal.java b/src/main/java/org/jabref/logic/layout/format/Ordinal.java index 5587828634e..85290643e79 100644 --- a/src/main/java/org/jabref/logic/layout/format/Ordinal.java +++ b/src/main/java/org/jabref/logic/layout/format/Ordinal.java @@ -23,21 +23,14 @@ public String format(String fieldText) { while (m.find()) { String result = m.group(1); int value = Integer.parseInt(result); - String ordinalString; - switch (value) { - case 1: - ordinalString = "st"; - break; - case 2: - ordinalString = "nd"; - break; - case 3: - ordinalString = "rd"; - break; - default: - ordinalString = "th"; - break; - } + //CHECKSTYLE:OFF + String ordinalString = switch (value) { + case 1 -> "st"; + case 2 -> "nd"; + case 3 -> "rd"; + default -> "th"; + }; + //CHECKSTYLE:ON m.appendReplacement(sb, result + ordinalString); } m.appendTail(sb);