From 6ea5acf682dec9e234df216e61a60bb23cdd5d0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 19 Feb 2013 20:15:40 +0100 Subject: [PATCH] Add function to extract the season number of an episode. This can be used to create a multimap by season from an iterable. --- .../java/net/pterodactylus/rhynodge/states/EpisodeState.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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; -- 2.7.4