Advertisement
Guest User

Untitled

a guest
Mar 14th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. package kam.albert.domain.test.case1;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public class MyPost {
  7.     private String id;
  8.  
  9.     MyComments<MyComment> myComments = new MyComments<>();
  10.  
  11.     public MyPost(String id) {
  12.         this.id = id;
  13.     }
  14.  
  15.     public MyComment addComment(String id, String comment) {
  16.         MyComment myComment = new MyComment(id, comment);
  17.         this.myComments.add(myComment);
  18.         return myComment;
  19.     }
  20.  
  21.     public MyComments<MyComment> getMyComments() {
  22.         return this.myComments;
  23.     }
  24.  
  25.     static class MyComments<T> {
  26.         List<T> comments = new ArrayList<>();
  27.         void add(T myBean) {
  28.             this.comments.add(myBean);
  29.         }
  30.     }
  31.  
  32.     static class MyComment extends MyAbstractClass {
  33.         // these are stored and retrieved fine
  34.         String commentId, comment;
  35.         public MyComment(String commentId, String comment) {
  36.             this.commentId = commentId;
  37.             this.comment = comment;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement