Remove unnecessary unmodifiable collection wrappers.

This commit is contained in:
akwizgran
2016-11-16 16:19:47 +00:00
parent 68abf8ba1a
commit f4c26d9cc7
16 changed files with 68 additions and 56 deletions

View File

@@ -9,7 +9,6 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.logging.Logger;
@@ -114,7 +113,7 @@ implements RemovableDriveMonitor.Callback {
} catch (IOException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
return Collections.unmodifiableList(matches);
return matches;
}
@Override

View File

@@ -3,7 +3,6 @@ package org.briarproject.plugins.file;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
@@ -13,8 +12,9 @@ abstract class UnixRemovableDriveFinder implements RemovableDriveFinder {
protected abstract String parseMountPoint(String line);
protected abstract boolean isRemovableDriveMountPoint(String path);
@Override
public List<File> findRemovableDrives() throws IOException {
List<File> drives = new ArrayList<File>();
List<File> drives = new ArrayList<>();
Process p = new ProcessBuilder(getMountCommand()).start();
Scanner s = new Scanner(p.getInputStream(), "UTF-8");
try {
@@ -35,6 +35,6 @@ abstract class UnixRemovableDriveFinder implements RemovableDriveFinder {
} finally {
s.close();
}
return Collections.unmodifiableList(drives);
return drives;
}
}

View File

@@ -1,23 +1,23 @@
package org.briarproject.plugins.file;
import com.sun.jna.platform.win32.Kernel32;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import com.sun.jna.platform.win32.Kernel32;
class WindowsRemovableDriveFinder implements RemovableDriveFinder {
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364939.aspx
private static final int DRIVE_REMOVABLE = 2;
@Override
public Collection<File> findRemovableDrives() throws IOException {
File[] roots = File.listRoots();
if (roots == null) throw new IOException();
List<File> drives = new ArrayList<File>();
List<File> drives = new ArrayList<>();
for (File root : roots) {
try {
int type = Kernel32.INSTANCE.GetDriveType(root.getPath());
@@ -26,6 +26,6 @@ class WindowsRemovableDriveFinder implements RemovableDriveFinder {
throw new IOException(e);
}
}
return Collections.unmodifiableList(drives);
return drives;
}
}