✨ Add movie descriptions to new movies section
[rhynodge.git] / src / main / java / net / pterodactylus / rhynodge / filters / webpages / savoy / Movie.java
1 package net.pterodactylus.rhynodge.filters.webpages.savoy;
2
3 import com.fasterxml.jackson.annotation.JsonProperty;
4
5 import java.util.ArrayList;
6 import java.util.List;
7 import java.util.Objects;
8 import java.util.stream.Collectors;
9
10 import static java.lang.String.format;
11
12 /**
13  * Information about a movie.
14  *
15  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
16  */
17 public class Movie {
18
19         @JsonProperty
20         private final String name;
21
22         @JsonProperty
23         private final String imageUrl;
24
25         @JsonProperty
26         private final String description;
27
28         @JsonProperty
29         private final List<Performance> performances = new ArrayList<>();
30
31         public Movie() {
32                 this("", "", "");
33         }
34
35         public Movie(String name, String imageUrl) {
36                 this(name, imageUrl, "");
37         }
38
39         public Movie(String name, String imageUrl, String description) {
40                 this.name = name;
41                 this.imageUrl = imageUrl;
42                 this.description = description;
43         }
44
45         public String getName() {
46                 return name;
47         }
48
49         public String getImageUrl() {
50                 return imageUrl;
51         }
52
53         public String getDescription() {
54                 return description;
55         }
56
57         public List<Performance> getPerformances() {
58                 return performances;
59         }
60
61         public void addPerformance(Performance performance) {
62                 performances.add(performance);
63         }
64
65         @Override
66         public String toString() {
67                 return format("%s (%s, %s, %s)", name, imageUrl, description, performances.stream().map(link -> String.format("%s: %s", link.getTime(), link.getLink())).collect(Collectors.joining(", ")));
68         }
69
70         @Override
71         public int hashCode() {
72                 return Objects.hash(name, imageUrl, description, performances);
73         }
74
75         @Override
76         public boolean equals(Object o) {
77                 if (this == o) return true;
78                 if (o == null || getClass() != o.getClass()) return false;
79                 Movie movie = (Movie) o;
80                 return Objects.equals(name, movie.name) && Objects.equals(imageUrl, movie.imageUrl) && Objects.equals(description, movie.description) && Objects.equals(performances, movie.performances);
81         }
82
83 }