You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
995 B
40 lines
995 B
package com.example.datacollect.repository;
|
|
|
|
import com.example.datacollect.model.Article;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
public class ArticleRepository {
|
|
private final List<Article> articles = new ArrayList<>();
|
|
|
|
public void add(Article article) {
|
|
if (article == null) {
|
|
throw new IllegalArgumentException("Article cannot be null");
|
|
}
|
|
articles.add(article);
|
|
}
|
|
|
|
public void addALL(List<Article> articleList){
|
|
if (articleList ==null){
|
|
throw new IllegalArgumentException("List cannot be null");
|
|
}
|
|
for (Article article : articleList){
|
|
if (article !=null){
|
|
articles.add(article);
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<Article> getAll() {
|
|
return Collections.unmodifiableList(articles);
|
|
}
|
|
|
|
public int size() {
|
|
return articles.size();
|
|
}
|
|
|
|
public void clear() {
|
|
articles.clear();
|
|
}
|
|
}
|
|
|