Skip to content

Instantly share code, notes, and snippets.

@taywils
Created December 9, 2013 01:43
Show Gist options
  • Save taywils/7866271 to your computer and use it in GitHub Desktop.
Save taywils/7866271 to your computer and use it in GitHub Desktop.
spark_storage_step_1_2
import java.util.ArrayList;
public class ArticleServletDao<T extends Article> implements ArticleDbService<T> {
ArrayList<T> storage;
public ArticleServletDao() {
storage = new ArrayList<T>();
}
@Override
public Boolean create(T entity) {
storage.add(entity);
return null;
}
@Override
public T readOne(int id) {
return storage.get(id);
}
@Override
public ArrayList<T> readAll() {
return storage;
}
@Override
public Boolean update(int id, String title, String summary, String content) {
T entity = storage.get(id);
entity.setSummary(summary);
entity.setTitle(title);
entity.setContent(content);
return true;
}
@Override
public Boolean delete(int id) {
storage.get(id).delete();
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment