X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Frhynodge%2Fstates%2FEpisodeState.java;h=78ca478204bce65728abe448819f559296617610;hb=75dffc0a110405807d5e6a6dd9e0815299d894ad;hp=c604634a105d14f79f63544bbd9b6a9b6cd488a1;hpb=9871b8a902d59f6e8eade050d18c77026b6ecc60;p=rhynodge.git diff --git a/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java b/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java index c604634..78ca478 100644 --- a/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java +++ b/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java @@ -29,6 +29,7 @@ import net.pterodactylus.rhynodge.states.EpisodeState.Episode; import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Function; /** * {@link State} implementation that stores episodes of TV shows, parsed via @@ -64,6 +65,11 @@ public class EpisodeState extends AbstractState implements Iterable { // ACCESSORS // + @Override + public boolean isEmpty() { + return episodes.isEmpty(); + } + /** * Returns all episodes contained in this state. * @@ -100,6 +106,15 @@ public class EpisodeState extends AbstractState implements Iterable { */ public static class Episode implements Comparable, Iterable { + /** Function to extract the season of an episode. */ + public static final Function BY_SEASON = new Function() { + + @Override + public Integer apply(Episode episode) { + return (episode != null ) ? episode.season() : -1; + } + }; + /** The season of the episode. */ @JsonProperty private final int season; @@ -184,7 +199,9 @@ public class EpisodeState extends AbstractState implements Iterable { * The torrent file to add */ public void addTorrentFile(TorrentFile torrentFile) { - torrentFiles.add(torrentFile); + if (!torrentFiles.contains(torrentFile)) { + torrentFiles.add(torrentFile); + } } //