File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/main/java/com/xxmicloxx/NoteBlockAPI/model Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 22
33import java .util .ArrayList ;
44import java .util .Arrays ;
5+ import java .util .List ;
56
67public class Playlist {
78
89 ArrayList <Song > songs = new ArrayList <>();
910
1011 public Playlist (Song ...songs ){
12+ if (songs .length == 0 ){
13+ throw new IllegalArgumentException ("Cannot create empty playlist" );
14+ }
15+ checkNull (songs );
1116 this .songs .addAll (Arrays .asList (songs ));
1217 }
1318
@@ -16,9 +21,20 @@ public Playlist(Song ...songs){
1621 * @param songs
1722 */
1823 public void add (Song ...songs ){
24+ if (songs .length == 0 ){
25+ return ;
26+ }
27+ checkNull (songs );
1928 this .songs .addAll (Arrays .asList (songs ));
2029 }
2130
31+ private void checkNull (Song ...songs ){
32+ List <Song > songList = Arrays .asList (songs );
33+ if (songList .contains (null )){
34+ throw new IllegalArgumentException ("Cannot add null to playlist" );
35+ }
36+ }
37+
2238 /**
2339 * Removes songs from playlist
2440 * @param songs
You can’t perform that action at this time.
0 commit comments