Skip to content
This repository has been archived by the owner on Sep 27, 2018. It is now read-only.

Commit

Permalink
Issue #93. Handle when there is not current broadcast for the given c…
Browse files Browse the repository at this point in the history
…hannel.
  • Loading branch information
Florent Biville committed Feb 20, 2013
1 parent f755121 commit 608cf38
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/main/java/tv/esporx/services/TimelineService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import tv.esporx.repositories.OccurrenceRepository;
import tv.esporx.services.timeline.Timeline;

import java.util.NoSuchElementException;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.find;
Expand All @@ -33,12 +35,17 @@ public Timeline getTimeline(DateTime start, DateTime end) {
public Occurrence findCurrentBroadcastByChannel(final Channel channel) {
DateTime start = toStartHour(new DateTime());
Timeline timeline = this.getTimeline(start, start.plusHours(1));
return find(timeline.perHourMultimap().values(), new Predicate<Occurrence>() {
@Override
public boolean apply(Occurrence input) {
return input.getChannels().contains(channel);
}
});
try {
return find(timeline.perHourMultimap().values(), new Predicate<Occurrence>() {
@Override
public boolean apply(Occurrence input) {
return input.getChannels().contains(channel);
}
});
}
catch (NoSuchElementException e) {
return null;
}
}

private void checkSanity(DateTime startDay, DateTime endDay) {
Expand Down

0 comments on commit 608cf38

Please sign in to comment.