Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<property name="header" value=""/>
</module>

<!-- BeforeExecutionFileFilters is required for sources that are based on java14 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="AuthorAndsReplacer.java|Ordinal.java" />
</module>

<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml"/>
</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
23 changes: 8 additions & 15 deletions src/main/java/org/jabref/logic/layout/format/Ordinal.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down