Wiki

Imprimir Propiedades
Blog_with_users_create_domain_classes

Adding domain classes

 

Now, we have to model the domain related to the application. In this case, we are going to implement a blog in which two classes are involved:

  • Post: This class represents posts to write in the blog.
  • Comment: This class represents comments associated to posts.

 

We create both classes with the POJO approach in org.romulus.blog.domain package.

public class Post {

 

    private Date postedOn;
    private String title;
    private String content;
    private ArrayList<Comment> comments = new ArrayList<Comment>();

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getPostedOn() {
        return postedOn;
    }

    public void setPostedOn(Date postedOn) {
        this.postedOn = postedOn;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public ArrayList<Comment> getComments() {
        return comments;
    }

    public void setComments(ArrayList<Comment> comments) {
        this.comments = comments;
    }
}

public class Comment {
   
    private String text;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}

1022 Accesos, 0 Ficheros adjuntos 0 Ficheros adjuntos

  • Comentarios