Created
December 9, 2013 01:43
-
-
Save taywils/7866271 to your computer and use it in GitHub Desktop.
spark_storage_step_1_2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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