From: David ‘Bombe’ Roden Date: Mon, 18 Feb 2013 20:58:21 +0000 (+0100) Subject: Make episodes sortable. X-Git-Tag: 0.1~24 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9871b8a902d59f6e8eade050d18c77026b6ecc60;p=rhynodge.git Make episodes sortable. --- 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 //