Skip to content

Commit

Permalink
convert Inner classes to record classes (#11838) (#11867)
Browse files Browse the repository at this point in the history
Co-authored-by: leaf-soba <[email protected]>
  • Loading branch information
subhramit and leaf-soba authored Sep 30, 2024
1 parent a47b338 commit b5c967c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 43 deletions.
1 change: 0 additions & 1 deletion src/main/java/org/jabref/gui/entryeditor/SourceTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public int getLocationOffset(int x, int y) {

@Override
public void cancelLatestCommittedText() {
return;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -91,15 +92,7 @@ private String convertToString(BufferedReader input) {
/**
* Small pair-class to ensure the right order of the recommendations.
*/
private static class RankedBibEntry {

public BibEntry entry;
public Integer rank;

public RankedBibEntry(BibEntry entry, Integer rank) {
this.rank = rank;
this.entry = entry;
}
private record RankedBibEntry(BibEntry entry, Integer rank) {
}

/**
Expand All @@ -126,8 +119,7 @@ private void parse(BufferedReader input) throws IOException {
}

// Sort bib entries according to rank
rankedBibEntries.sort((RankedBibEntry rankedBibEntry1,
RankedBibEntry rankedBibEntry2) -> rankedBibEntry1.rank.compareTo(rankedBibEntry2.rank));
rankedBibEntries.sort(Comparator.comparing((RankedBibEntry rankedBibEntry) -> rankedBibEntry.rank));
List<BibEntry> bibEntries = rankedBibEntries.stream().map(e -> e.entry).collect(Collectors.toList());

bibDatabase.insertEntries(bibEntries);
Expand Down
20 changes: 5 additions & 15 deletions src/main/java/org/jabref/logic/openoffice/action/EditMerge.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,11 @@ public static boolean mergeCitationGroups(XTextDocument doc, OOFrontend frontend
return madeModifications;
}

private static class JoinableGroupData {
/**
* A list of consecutive citation groups only separated by spaces.
*/
List<CitationGroup> group;

/**
* A cursor covering the XTextRange of each entry in group (and the spaces between them)
*/
XTextCursor groupCursor;

JoinableGroupData(List<CitationGroup> group, XTextCursor groupCursor) {
this.group = group;
this.groupCursor = groupCursor;
}
/**
* @param group A list of consecutive citation groups only separated by spaces.
* @param groupCursor A cursor covering the XTextRange of each entry in group (and the spaces between them)
*/
private record JoinableGroupData(List<CitationGroup> group, XTextCursor groupCursor) {
}

private static class ScanState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static <T> List<RangeSortable<T>> visualSort(List<RangeSortable<T>> input
// collect ordered result
List<RangeSortable<T>> result = new ArrayList<>(comparableMarks.size());
for (ComparableMark<RangeSortable<T>> mark : comparableMarks) {
result.add(mark.getContent());
result.add(mark.content());
}

if (result.size() != inputSize) {
Expand Down Expand Up @@ -111,20 +111,6 @@ private static <T> int compareTopToBottomLeftToRight(ComparableMark<T> a, Compar
* <p>
* Used for sorting reference marks by their visual positions.
*/
private static class ComparableMark<T> {

private final Point position;
private final int indexInPosition;
private final T content;

public ComparableMark(Point position, int indexInPosition, T content) {
this.position = position;
this.indexInPosition = indexInPosition;
this.content = content;
}

public T getContent() {
return content;
}
private record ComparableMark<T>(Point position, int indexInPosition, T content) {
}
}

0 comments on commit b5c967c

Please sign in to comment.