Skip to content
Closed
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ dependencies {
testImplementation "org.testfx:testfx-junit5:4.0.17-alpha-SNAPSHOT"
testImplementation "org.hamcrest:hamcrest-library:2.2"

checkstyle 'com.puppycrawl.tools:checkstyle:8.30'
checkstyle 'com.puppycrawl.tools:checkstyle:8.31'
xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '2.3.2'
jython 'org.python:jython-standalone:2.7.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,18 @@ public String format(String fieldText) {
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("; ");
case 1 -> s = authors[0]; // just no action
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use the full power of the switch expressions and write String s = switch (...) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntelliJ did not recommend it ^^. Just submit an update here :)

case 2 -> s = 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]);
s = sb.toString();
}
sb.append(authors[i]).append(" & ").append(authors[i + 1]);
s = sb.toString();
break;
}

return s;
Expand Down
21 changes: 6 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,12 @@ 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;
}
String ordinalString = switch (value) {
case 1 -> "st";
case 2 -> "nd";
case 3 -> "rd";
default -> "th";
};
m.appendReplacement(sb, result + ordinalString);
}
m.appendTail(sb);
Expand Down