Enhance genre removal logic in Album class

Update removeGenre method to check for null IDs.
This commit is contained in:
Gustavo Henrique Miranda 2025-12-08 00:14:51 -03:00 committed by GitHub
parent 7b7d1e7348
commit 9e3516aacb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -98,9 +98,9 @@ public class Album {
}
public void removeGenre(Genre genre) {
albumGenres.removeIf(ag ->
ag.getGenre() != null && ag.getGenre().getId().equals(genre.getId())
);
ag.getGenre() != null &&
ag.getGenre().getId() != null &&
ag.getGenre().getId().equals(genre.getId())
}
// Método conveniente para pegar os gêneros
@ -221,4 +221,4 @@ public class Album {
", year=" + year +
'}';
}
}
}