1 changed files with 31 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||
package com.example.moviecli.repository; |
|||
|
|||
import com.example.moviecli.model.Movie; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
|
|||
public class MovieRepository { |
|||
private final List<Movie> movies = new ArrayList<>(); |
|||
|
|||
public void add(Movie movie) { |
|||
if (movie == null) throw new IllegalArgumentException(); |
|||
movies.add(movie); |
|||
} |
|||
|
|||
public void addAll(List<Movie> list) { |
|||
movies.addAll(list); |
|||
} |
|||
|
|||
public List<Movie> getAll() { |
|||
return Collections.unmodifiableList(movies); |
|||
} |
|||
|
|||
public void clear() { |
|||
movies.clear(); |
|||
} |
|||
|
|||
public int size() { |
|||
return movies.size(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue