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
*/
public static class Episode implements Comparable<Episode>, Iterable<TorrentFile> {
+ /** Function to extract the season of an episode. */
+ public static final Function<Episode, Integer> BY_SEASON = new Function<Episode, Integer>() {
+
+ @Override
+ public Integer apply(Episode episode) {
+ return (episode != null ) ? episode.season() : -1;
+ }
+ };
+
/** The season of the episode. */
@JsonProperty
private final int season;
* The torrent file to add
*/
public void addTorrentFile(TorrentFile torrentFile) {
- torrentFiles.add(torrentFile);
+ if (!torrentFiles.contains(torrentFile)) {
+ torrentFiles.add(torrentFile);
+ }
}
//