use of no.stelar7.api.l4j8.pojo.match.MatchTimeline in project L4J8 by stelar7.
the class TimelineBuilder method get.
/**
* Returns the timeline relating to a match.
* Not avaliable for matches older than a year
*
* @return MatchTimeline if avaliable
*/
public MatchTimeline get() {
if (this.id == -1 || this.platform == Platform.UNKNOWN) {
return null;
}
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.MATCH_ID_PLACEHOLDER, String.valueOf(this.id)).withEndpoint(URLEndpoint.V3_TIMELINE).withPlatform(this.platform);
Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_TIMELINE, this.platform, this.id);
if (chl.isPresent()) {
return (MatchTimeline) chl.get();
}
try {
MatchTimeline timeline = (MatchTimeline) builder.build();
DataCall.getCacheProvider().store(URLEndpoint.V3_TIMELINE, timeline, this.platform, this.id);
return timeline;
} catch (ClassCastException e) {
return null;
}
}
Aggregations