From: David ‘Bombe’ Roden Date: Tue, 19 Feb 2013 19:15:40 +0000 (+0100) Subject: Add function to extract the season number of an episode. X-Git-Tag: 0.1~19 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6ea5acf682dec9e234df216e61a60bb23cdd5d0c;p=rhynodge.git Add function to extract the season number of an episode. This can be used to create a multimap by season from an iterable. --- diff --git a/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java b/src/main/java/net/pterodactylus/rhynodge/states/EpisodeState.java index c604634..7ed3dce 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 @@ -100,6 +101,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.season(); + } + }; + /** The season of the episode. */ @JsonProperty private final int season;