🚧 Make Movie and Performance JSON-serializable
[rhynodge.git] / src / main / java / net / pterodactylus / rhynodge / filters / webpages / savoy / Performance.java
index 4585e6e..c50dd31 100644 (file)
@@ -1,17 +1,24 @@
 package net.pterodactylus.rhynodge.filters.webpages.savoy;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 import java.time.LocalDateTime;
-import java.util.Comparator;
+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 link;
 
-       public static final Comparator<Performance> byTime = (leftPerformance, rightPerformance) -> leftPerformance.getTime().compareTo(rightPerformance.getTime());
+       public Performance() {
+               this(null, null);
+       }
 
        public Performance(LocalDateTime time, String link) {
                this.time = time;
@@ -26,4 +33,17 @@ public class Performance {
                return link;
        }
 
+       @Override
+       public int hashCode() {
+               return Objects.hash(time, 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(link, that.link);
+       }
+
 }