+++ /dev/null
-package net.pterodactylus.rhynodge.filters.webpages.savoy;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-import static java.lang.String.format;
-import static java.util.Collections.emptyList;
-
-/**
- * Information about a movie.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class Movie {
-
- @JsonProperty
- private final String name;
-
- @JsonProperty
- private final String imageUrl;
-
- @JsonProperty
- private final String description;
-
- @JsonProperty
- private final List<Performance> performances = new ArrayList<>();
-
- public Movie() {
- this("", "", "");
- }
-
- public Movie(String name, String imageUrl) {
- this(name, imageUrl, "");
- }
-
- public Movie(String name, String imageUrl, String description) {
- this(name, imageUrl, description, emptyList());
- }
-
- public Movie(String name, String imageUrl, String description, Collection<Performance> performances) {
- this.name = name;
- this.imageUrl = imageUrl;
- this.description = description;
- this.performances.addAll(performances);
- }
-
- public String getName() {
- return name;
- }
-
- public String getImageUrl() {
- return imageUrl;
- }
-
- public String getDescription() {
- return description;
- }
-
- public List<Performance> getPerformances() {
- return performances;
- }
-
- @Override
- public String toString() {
- return format("%s (%s, %s, %s)", name, imageUrl, description, performances.stream().map(link -> String.format("%s: %s", link.getTime(), link.getLink())).collect(Collectors.joining(", ")));
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, imageUrl, description, 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(description, movie.description) && Objects.equals(performances, movie.performances);
- }
-
-}
--- /dev/null
+package net.pterodactylus.rhynodge.filters.webpages.savoy
+
+import com.fasterxml.jackson.annotation.JsonProperty
+import java.util.Objects
+import java.util.stream.Collectors
+
+/**
+ * Information about a movie.
+ */
+data class Movie @JvmOverloads constructor(
+ @JvmField @field:JsonProperty val name: String = "",
+ @JvmField @field:JsonProperty val imageUrl: String = "",
+ @JvmField @field:JsonProperty val description: String = "",
+ @JvmField @field:JsonProperty val performances: Collection<Performance> = emptyList()
+)
return new TypeSafeDiagnosingMatcher<Movie>() {
@Override
protected boolean matchesSafely(Movie movie, Description mismatchDescription) {
- if (!movie.getName().equals(name)) {
- mismatchDescription.appendText("movie is named ").appendValue(movie.getName());
+ if (!movie.name.equals(name)) {
+ mismatchDescription.appendText("movie is named ").appendValue(movie.name);
return false;
}
- if (!movie.getImageUrl().equals(imageUrl)) {
- mismatchDescription.appendText("image URL is ").appendValue(movie.getImageUrl());
+ if (!movie.imageUrl.equals(imageUrl)) {
+ mismatchDescription.appendText("image URL is ").appendValue(movie.imageUrl);
return false;
}
- if (!descriptionMatcher.matches(movie.getDescription())) {
- descriptionMatcher.describeMismatch(movie.getDescription(), mismatchDescription);
+ if (!descriptionMatcher.matches(movie.description)) {
+ descriptionMatcher.describeMismatch(movie.description, mismatchDescription);
return false;
}
- List<Performance> performances = new ArrayList<>(movie.getPerformances());
+ List<Performance> performances = new ArrayList<>(movie.performances);
if (performances.size() != presentationTimesTypesAndLinks.length) {
mismatchDescription.appendText("has ").appendValue(performances.size()).appendText(" presentations");
return false;