Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package kam.albert.domain.test.case1;
- import java.util.ArrayList;
- import java.util.List;
- public class MyPost {
- private String id;
- MyComments<MyComment> myComments = new MyComments<>();
- public MyPost(String id) {
- this.id = id;
- }
- public MyComment addComment(String id, String comment) {
- MyComment myComment = new MyComment(id, comment);
- this.myComments.add(myComment);
- return myComment;
- }
- public MyComments<MyComment> getMyComments() {
- return this.myComments;
- }
- static class MyComments<T> {
- List<T> comments = new ArrayList<>();
- void add(T myBean) {
- this.comments.add(myBean);
- }
- }
- static class MyComment extends MyAbstractClass {
- // these are stored and retrieved fine
- String commentId, comment;
- public MyComment(String commentId, String comment) {
- this.commentId = commentId;
- this.comment = comment;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement