Skip to content

Commit e3c6c26

Browse files
committed
simplify
1 parent 0088d0d commit e3c6c26

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

jabgui/src/main/java/org/jabref/gui/preview/ClipboardContentGenerator.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import javafx.scene.input.ClipboardContent;
99

10+
import org.jabref.logic.bst.BstPreviewLayout;
1011
import org.jabref.logic.citationstyle.CitationStyleGenerator;
1112
import org.jabref.logic.citationstyle.CitationStyleOutputFormat;
1213
import org.jabref.logic.citationstyle.CitationStylePreviewLayout;
@@ -24,28 +25,22 @@
2425
import com.airhacks.afterburner.injection.Injector;
2526
import com.google.common.annotations.VisibleForTesting;
2627

27-
public class ClipboardContentGenerator {
28-
29-
private final PreviewPreferences previewPreferences;
30-
private final LayoutFormatterPreferences layoutFormatterPreferences;
31-
private final JournalAbbreviationRepository abbreviationRepository;
32-
33-
public ClipboardContentGenerator(PreviewPreferences previewPreferences,
34-
LayoutFormatterPreferences layoutFormatterPreferences,
35-
JournalAbbreviationRepository abbreviationRepository) {
36-
this.previewPreferences = previewPreferences;
37-
this.layoutFormatterPreferences = layoutFormatterPreferences;
38-
this.abbreviationRepository = abbreviationRepository;
39-
}
28+
public record ClipboardContentGenerator(
29+
PreviewPreferences previewPreferences,
30+
LayoutFormatterPreferences layoutFormatterPreferences,
31+
JournalAbbreviationRepository abbreviationRepository) {
4032

4133
public ClipboardContent generate(List<BibEntry> selectedEntries, CitationStyleOutputFormat outputFormat, BibDatabaseContext bibDatabaseContext) throws IOException {
4234
List<String> citations = generateCitations(selectedEntries, outputFormat, bibDatabaseContext);
4335
if (previewPreferences.getSelectedPreviewLayout() instanceof CitationStylePreviewLayout) {
4436
// if it's generated by a citation style take care of each output format
4537
return switch (outputFormat) {
46-
case HTML -> processHtml(citations);
47-
case TEXT -> processText(citations);
48-
case MARKDOWN -> processMarkdown(citations);
38+
case HTML ->
39+
processHtml(citations);
40+
case TEXT ->
41+
processText(citations);
42+
case MARKDOWN ->
43+
processMarkdown(citations);
4944
};
5045
} else {
5146
// if it is not a citation style take care of the preview
@@ -76,7 +71,7 @@ private List<String> generateCitations(List<BibEntry> selectedEntries, CitationS
7671
}
7772

7873
/**
79-
* Generates a plain text string out of the preview (based on {@link org.jabref.logic.layout.TextBasedPreviewLayout} or {@link org.jabref.logic.bst.BstPreviewLayout})
74+
* Generates a plain text string out of the preview (based on {@link TextBasedPreviewLayout} or {@link BstPreviewLayout})
8075
* and copies it additionally to the html to the clipboard (WYSIWYG Editors use the HTML, plain text editors the text)
8176
*/
8277
@VisibleForTesting
@@ -99,7 +94,7 @@ static ClipboardContent processText(List<String> citations) {
9994

10095
/**
10196
* Inserts each citation into a HTML body and copies it to the clipboard.
102-
* The given preview is based on {@link org.jabref.logic.citationstyle.CitationStylePreviewLayout}.
97+
* The given preview is based on {@link CitationStylePreviewLayout}.
10398
*/
10499
@VisibleForTesting
105100
static ClipboardContent processHtml(List<String> citations) {

0 commit comments

Comments
 (0)