Switched Optional logic to ifPresent where appropriate.
This commit is contained in:
parent
75f310e140
commit
9073242390
@ -18,17 +18,14 @@ public class LibraryTreeCellRenderer implements TreeCellRenderer {
|
||||
@Override
|
||||
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
|
||||
Object o = ((DefaultMutableTreeNode) value).getUserObject();
|
||||
label.setIcon(null);
|
||||
if (o != null) {
|
||||
label.setText(o.toString());
|
||||
if (o instanceof Album) {
|
||||
Album album = (Album) o;
|
||||
if (album.getAlbumArt().isPresent())
|
||||
label.setIcon(new ImageIcon(album.getAlbumArt().get()));
|
||||
else {
|
||||
label.setIcon(null);
|
||||
album.getAlbumArt().ifPresent(x -> label.setIcon(new ImageIcon(x)));
|
||||
}
|
||||
}
|
||||
} else
|
||||
label.setIcon(null);
|
||||
if (o != null)
|
||||
label.setText(o.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public final class LibraryUtils {
|
||||
public static void processSongs(Path rootDirectory) throws IOException {
|
||||
Files.walk(rootDirectory)
|
||||
.filter(f -> f.toString().matches(musicFileExtensionRegex))
|
||||
.map(LibraryUtils::autoParse).filter(Optional::isPresent).map(Optional::get).forEach(Gateway::addSong);
|
||||
.map(LibraryUtils::autoParse).forEach(x -> x.ifPresent(Gateway::addSong));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user