Use `removeIf` instead of doing this manually

master
jvoisin 5 years ago
parent f77a0d8b67
commit c0beca6a58
  1. 8
      airsonic-main/src/main/java/org/airsonic/player/ajax/PlayQueueService.java
  2. 8
      airsonic-main/src/main/java/org/airsonic/player/service/MediaFileService.java
  3. 8
      airsonic-main/src/main/java/org/airsonic/player/service/StatusService.java
  4. 8
      airsonic-main/src/main/java/org/airsonic/player/spring/SpringLiquibase.java

@ -275,13 +275,7 @@ public class PlayQueueService {
}
// Remove non-present files
Iterator<MediaFile> iterator = files.iterator();
while (iterator.hasNext()) {
MediaFile file = iterator.next();
if (!file.isPresent()) {
iterator.remove();
}
}
files.removeIf(file -> !file.isPresent());
Player player = getCurrentPlayer(request, response);
return doPlay(request, player, files).setStartPlayerAt(0);
}

@ -356,13 +356,7 @@ public class MediaFileService {
* Removes video files from the given list.
*/
public void removeVideoFiles(List<MediaFile> files) {
Iterator<MediaFile> iterator = files.iterator();
while (iterator.hasNext()) {
MediaFile file = iterator.next();
if (file.isVideo()) {
iterator.remove();
}
}
files.removeIf(MediaFile::isVideo);
}
public Date getMediaFileStarredDate(int id, String username) {

@ -131,13 +131,7 @@ public class StatusService {
}
public synchronized void addRemotePlay(PlayStatus playStatus) {
Iterator<PlayStatus> iterator = remotePlays.iterator();
while (iterator.hasNext()) {
PlayStatus rp = iterator.next();
if (rp.isExpired()) {
iterator.remove();
}
}
remotePlays.removeIf(PlayStatus::isExpired);
remotePlays.add(playStatus);
}

@ -65,12 +65,6 @@ public class SpringLiquibase extends liquibase.integration.spring.SpringLiquibas
}
private void removeCurrentHsqlDb(List<Database> implementedDatabases) {
Iterator<Database> iterator = implementedDatabases.iterator();
while (iterator.hasNext()) {
Database db = iterator.next();
if (db instanceof liquibase.database.core.HsqlDatabase) {
iterator.remove();
}
}
implementedDatabases.removeIf(db -> db instanceof liquibase.database.core.HsqlDatabase);
}
}

Loading…
Cancel
Save