♻️ Rename “TicketLink” to “Performance”
[rhynodge.git] / src / main / java / net / pterodactylus / rhynodge / filters / webpages / savoy / Movie.java
1 package net.pterodactylus.rhynodge.filters.webpages.savoy;
2
3 import static java.lang.String.format;
4
5 import java.util.ArrayList;
6 import java.util.Comparator;
7 import java.util.List;
8 import java.util.function.Predicate;
9 import java.util.stream.Collectors;
10
11 /**
12  * Information about a movie.
13  *
14  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
15  */
16 public class Movie {
17
18         private final String name;
19         private final List<Performance> performances = new ArrayList<>();
20
21         public static final Predicate<Movie> withPerformances = movie -> !movie.getPerformances().isEmpty();
22         public static final Comparator<Movie> byName = (leftMovie, rightMovie) -> leftMovie.getName().compareToIgnoreCase(rightMovie.getName());
23
24         public Movie(String name) {
25                 this.name = name;
26         }
27
28         public String getName() {
29                 return name;
30         }
31
32         public List<Performance> getPerformances() {
33                 return performances;
34         }
35
36         public void addPerformance(Performance performance) {
37                 performances.add(performance);
38         }
39
40         @Override
41         public String toString() {
42                 return format("%s (%s)", name, performances.stream().map(link -> String.format("%s: %s", link.getTime(), link.getLink())).collect(Collectors.joining(", ")));
43         }
44
45 }