Search in sources :

Example 1 with MatchTimeline

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;
    }
}
Also used : Optional(java.util.Optional) MatchTimeline(no.stelar7.api.l4j8.pojo.match.MatchTimeline)

Aggregations

Optional (java.util.Optional)1 MatchTimeline (no.stelar7.api.l4j8.pojo.match.MatchTimeline)1