Apply suggestions from code review

Co-authored by: Tobias Hagemann <tobihagemann@users.noreply.github.com>
This commit is contained in:
Armin Schrenk
2022-05-12 12:15:16 +02:00
parent 98002f63dc
commit 5832e8cd49
2 changed files with 3 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ import java.util.List;
public enum LocationPreset {
DROPBOX("Dropbox", "~/Dropbox"),
ICLOUD("iCloud Drive", "~/Library/Mobile Documents/com~apple~CloudDocs", "~/iCloudDrive"),
ICLOUDDRIVE("iCloud Drive", "~/Library/Mobile Documents/com~apple~CloudDocs", "~/iCloudDrive"),
GDRIVE("Google Drive", "~/Google Drive/My Drive", "~/Google Drive"),
MEGA("MEGA", "~/MEGA"),
ONEDRIVE("OneDrive", "~/OneDrive"),
@@ -43,12 +43,7 @@ public enum LocationPreset {
* @return the first existing path or null, if none exists.
*/
public Path existingPath() {
for (Path candidate : candidates) {
if (Files.isDirectory(candidate)) {
return candidate;
}
}
return null;
return candidates.stream().filter(Files::isDirectory).findFirst().orElse(null);
}
@Override

View File

@@ -26,7 +26,7 @@ public class ObservedLocationPresets {
@Inject
public ObservedLocationPresets() {
this.iclouddriveLocation = new SimpleObjectProperty<>(LocationPreset.ICLOUD.existingPath());
this.iclouddriveLocation = new SimpleObjectProperty<>(LocationPreset.ICLOUDDRIVE.existingPath());
this.dropboxLocation = new SimpleObjectProperty<>(LocationPreset.DROPBOX.existingPath());
this.gdriveLocation = new SimpleObjectProperty<>(LocationPreset.GDRIVE.existingPath());
this.onedriveLocation = new SimpleObjectProperty<>(LocationPreset.ONEDRIVE.existingPath());