From 9871b8a902d59f6e8eade050d18c77026b6ecc60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 18 Feb 2013 21:58:21 +0100 Subject: [PATCH] Make episodes sortable. --- .../rhynodge/states/EpisodeState.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java b/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java index d7d90b2..c604634 100644 --- a/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java +++ b/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java @@ -98,7 +98,7 @@ public class EpisodeState extends AbstractState implements Iterable { * * @author David ‘Bombe’ Roden */ - public static class Episode implements Iterable { + public static class Episode implements Comparable, Iterable { /** The season of the episode. */ @JsonProperty @@ -199,6 +199,26 @@ public class EpisodeState extends AbstractState implements Iterable { return torrentFiles.iterator(); } + /** + * {@inheritDoc} + */ + @Override + public int compareTo(Episode episode) { + if (season() < episode.season()) { + return -1; + } + if (season() > episode.season()) { + return 1; + } + if (episode() < episode.episode()) { + return -1; + } + if (episode() > episode.episode()) { + return 1; + } + return 0; + } + // // OBJECT METHODS // -- 2.7.4