From a64a72917db9c15fa06526cf9de37e75434d1c3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 8 Mar 2024 12:21:26 +0100 Subject: [PATCH] =?utf8?q?=E2=99=BB=EF=B8=8F=20Convert=20Performace=20to?= =?utf8?q?=20Kotlin=20data=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../filters/webpages/savoy/Performance.java | 57 ---------------------- .../rhynodge/filters/webpages/savoy/MovieState.kt | 4 +- .../rhynodge/filters/webpages/savoy/Performance.kt | 14 ++++++ 3 files changed, 16 insertions(+), 59 deletions(-) delete mode 100644 src/main/java/net/pterodactylus/rhynodge/filters/webpages/savoy/Performance.java create mode 100644 src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/Performance.kt diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/webpages/savoy/Performance.java b/src/main/java/net/pterodactylus/rhynodge/filters/webpages/savoy/Performance.java deleted file mode 100644 index dd4c165..0000000 --- a/src/main/java/net/pterodactylus/rhynodge/filters/webpages/savoy/Performance.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.pterodactylus.rhynodge.filters.webpages.savoy; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.time.LocalDateTime; -import java.util.Objects; - -/** - * Information about a performance and a link to buy a ticket. - */ -public class Performance { - - @JsonProperty - private final LocalDateTime time; - - @JsonProperty - private final String type; - - @JsonProperty - private final String link; - - public Performance() { - this(null, null, null); - } - - public Performance(LocalDateTime time, String type, String link) { - this.time = time; - this.type = type; - this.link = link; - } - - public LocalDateTime getTime() { - return time; - } - - public String getType() { - return type; - } - - public String getLink() { - return link; - } - - @Override - public int hashCode() { - return Objects.hash(time, type, link); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Performance that = (Performance) o; - return Objects.equals(time, that.time) && Objects.equals(type, that.type) && Objects.equals(link, that.link); - } - -} diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieState.kt b/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieState.kt index fa8a9c0..8d84b4f 100644 --- a/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieState.kt +++ b/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieState.kt @@ -84,7 +84,7 @@ class MovieState(@JsonProperty val movies: Collection, val newMovies: Col section("daily-programmes") { ol("days") { - movies.flatMap { it.performances.map(Performance::getTime).map(LocalDateTime::toLocalDate) }.distinct().sorted().forEach { date -> + movies.flatMap { it.performances.map(Performance::time).map(LocalDateTime::toLocalDate) }.distinct().sorted().forEach { date -> li("day") { attributes += "data-date" to "%tY-%, val newMovies: Col override fun triggered() = newMovies.isNotEmpty() || triggered private val earliestMovie = movies.minByOrNull { it.earliestPerformance ?: LocalDateTime.MAX } - private val Movie.earliestPerformance: LocalDateTime? get() = performances.minOfOrNull(Performance::getTime) + private val Movie.earliestPerformance: LocalDateTime? get() = performances.minOfOrNull(Performance::time) } diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/Performance.kt b/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/Performance.kt new file mode 100644 index 0000000..66ddacf --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/Performance.kt @@ -0,0 +1,14 @@ +package net.pterodactylus.rhynodge.filters.webpages.savoy + +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.LocalDateTime +import java.util.Objects + +/** + * Information about a performance and a link to buy a ticket. + */ +data class Performance @JvmOverloads constructor( + @field:JsonProperty val time: LocalDateTime = LocalDateTime.now(), + @field:JsonProperty val type: String = "", + @field:JsonProperty val link: String = "" +) -- 2.7.4