package de.codecentric.moviedatabase.movies.domain; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.UUID; public class Movie { private UUID id; private String title; private String description; private Date startDate; private Set<Tag> tags = new HashSet<Tag>(); private List<Comment> comments = new ArrayList<Comment>(); public Movie() { // pass } public Movie(UUID id, String title, String description, Date startDate) { this.id = id; this.title = title; this.description = description; this.startDate = startDate; } public Movie(String title, String description, Date startDate) { this(UUID.randomUUID(), title, description, startDate); } public UUID getId() { return id; } public String getTitle() { return title; } public String getDescription() { return description; } public Date getStartDate() { return startDate; } public void setDescription(String description) { this.description = description; } public void setStartDate(Date startDate) { this.startDate = startDate; } public void setTitle(String title) { this.title = title; } public Set<Tag> getTags() { return tags; } public List<Comment> getComments() { return comments; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((comments == null) ? 0 : comments.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((startDate == null) ? 0 : startDate.hashCode()); result = prime * result + ((title == null) ? 0 : title.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Movie other = (Movie) obj; if (comments == null) { if (other.comments != null) return false; } else if (!comments.equals(other.comments)) return false; if (description == null) { if (other.description != null) return false; } else if (!description.equals(other.description)) return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (startDate == null) { if (other.startDate != null) return false; } else if (!startDate.equals(other.startDate)) return false; if (title == null) { if (other.title != null) return false; } else if (!title.equals(other.title)) return false; return true; } }