package net.pterodactylus.rhynodge.filters.webpages.savoy;
-import static java.lang.String.format;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
-import java.util.Comparator;
import java.util.List;
-import java.util.function.Predicate;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static java.lang.String.format;
/**
* Information about a movie.
*/
public class Movie {
+ @JsonProperty
private final String name;
- private final List<TicketLink> ticketLinks = new ArrayList<>();
- public static final Predicate<Movie> withPresentations = movie -> !movie.getTicketLinks().isEmpty();
- public static final Comparator<Movie> byName = (leftMovie, rightMovie) -> leftMovie.getName().compareToIgnoreCase(rightMovie.getName());
+ @JsonProperty
+ private final String imageUrl;
+
+ @JsonProperty
+ private final List<Performance> performances = new ArrayList<>();
- public Movie(String name) {
+ public Movie() {
+ this("", "");
+ }
+
+ public Movie(String name, String imageUrl) {
this.name = name;
+ this.imageUrl = imageUrl;
}
public String getName() {
return name;
}
- public List<TicketLink> getTicketLinks() {
- return ticketLinks;
+ public String getImageUrl() {
+ return imageUrl;
+ }
+
+ public List<Performance> getPerformances() {
+ return performances;
}
- public void addTicketLink(TicketLink ticketLink) {
- ticketLinks.add(ticketLink);
+ public void addPerformance(Performance performance) {
+ performances.add(performance);
}
@Override
public String toString() {
- return format("%s (%d)", name, ticketLinks.size());
+ return format("%s (%s, %s)", name, imageUrl, performances.stream().map(link -> String.format("%s: %s", link.getTime(), link.getLink())).collect(Collectors.joining(", ")));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, imageUrl, performances);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Movie movie = (Movie) o;
+ return Objects.equals(name, movie.name) && Objects.equals(imageUrl, movie.imageUrl) && Objects.equals(performances, movie.performances);
}
}