2 Working with the cached version API
4 Dmitry Samoshin aka gotty
9 ~~ Copyright (c) 2017. Developed by Hedgecode.
11 ~~ Licensed under the Apache License, Version 2.0 (the "License");
12 ~~ you may not use this file except in compliance with the License.
13 ~~ You may obtain a copy of the License at
15 ~~ http://www.apache.org/licenses/LICENSE-2.0
17 ~~ Unless required by applicable law or agreed to in writing, software
18 ~~ distributed under the License is distributed on an "AS IS" BASIS,
19 ~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 ~~ See the License for the specific language governing permissions and
21 ~~ limitations under the License.
23 ~~ NOTE: For help with the syntax of this file, see:
24 ~~ http://maven.apache.org/doxia/references/apt-format.html
26 Working with the cached version API
28 When you first call the API method to get the main interface of the library
31 SnookerScoreAPI api = Snooker.API();
34 by default we get the cached implementation of the API interface <<<SnookerScoreAPI>>>.\
35 What are its advantages?
39 Firstly, when using the cached version of the interface for various queries, you get a full range
40 of useful information. For example, when requesting current matches, the sample will contain
41 links to the tournament (object <<<Event>>>) as well as to the players
42 participating in each match (objects <<<Player>>>) in addition to other information:
45 SnookerScoreAPI api = Snooker.API();
46 OngoingMatches matches = api.getOngoingMatches();
47 for (OngoingMatch match : matches) {
48 Event event = match.event();
49 Player player1 = match.player1();
50 Player player2 = match.player2();
54 Whereas when working with the noncached version of the interface, you will have to make
55 additional queries about the tournament and players in order to get full information
56 about the ongoing matches:
59 SnookerScoreAPI api = Snooker.uncachedAPI();
60 OngoingMatches matches = api.getOngoingMatches();
61 for (OngoingMatch match : matches) {
62 Event event = api.getEvent(match.eventId());
63 Player player1 = api.getPlayer(match.player1Id());
64 Player player2 = api.getPlayer(match.player2Id());
70 Secondly, in the cached version of the interface, you are given the opportunity to specify
71 the current season, with the events of which in the future you are going to work
72 by requesting tournaments and matches:
75 SnookerScoreAPI api = Snooker.API();
76 api.setCurrentSeason(Season.getSeason(2015));
81 P.S. If you need to use the noncached version of the API, you can get it as follows:
84 SnookerScoreAPI uncachedApi = Snooker.uncachedAPI();