Skip to content

Commit 30e1462

Browse files
committed
PDFBOX-5660: refactor
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1932610 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8551f8b commit 30e1462

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ public RecentFiles(Class<?> className, int maximumFile)
5151
this.maximum = maximumFile;
5252
this.pref = Preferences.userNodeForPackage(className);
5353
filePaths = readHistoryFromPref();
54-
if (filePaths == null)
55-
{
56-
filePaths = new ArrayDeque<>();
57-
}
5854
}
5955

6056
/**
@@ -108,18 +104,14 @@ public void removeFile(String path)
108104
*/
109105
public List<String> getFiles()
110106
{
111-
if (!isEmpty())
107+
List<String> files = filePaths.stream().
108+
filter(path -> new File(path).exists()).
109+
collect(Collectors.toList());
110+
if (files.size() > maximum)
112111
{
113-
List<String> files = filePaths.stream().
114-
filter(path -> new File(path).exists()).
115-
collect(Collectors.toList());
116-
if (files.size() > maximum)
117-
{
118-
files.remove(0);
119-
}
120-
return files;
112+
files.remove(0);
121113
}
122-
return null;
114+
return files;
123115
}
124116

125117
/**
@@ -175,12 +167,7 @@ private Queue<String> readHistoryFromPref()
175167
{
176168
Preferences node = pref.node(KEY);
177169
int historyLength = node.getInt(HISTORY_LENGTH, 0);
178-
if (historyLength == 0)
179-
{
180-
return null;
181-
}
182170
Queue<String> history = new ArrayDeque<>();
183-
184171
for (int i = 1; i <= historyLength; i++)
185172
{
186173
int totalPieces = node.getInt(String.format(PIECES_LENGTH_KEY, i), 0);

0 commit comments

Comments
 (0)