Refactor Line separator for Mac and add APIFootballProvider
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class APIFootballMatchesProvider {
|
||||
|
||||
APIFootballConnector conn;
|
||||
public APIFootballMatchesProvider(int season) {
|
||||
this.conn = new APIFootballConnector(season - 1);
|
||||
}
|
||||
|
||||
public ArrayList<APIFootballMatch> getAPIFootballMatchesFromConfig(JSONArray config) {
|
||||
ArrayList<APIFootballMatch> apiFootballMatches = new ArrayList<>();
|
||||
for (Object singleConfigObject : config) {
|
||||
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
||||
String type = (String) singleConfig.get("type");
|
||||
switch (type) {
|
||||
case "AllMatchesOfMatchday":
|
||||
int matchesLeague = ((Long) singleConfig.get("matchesLeague")).intValue();
|
||||
int leagueMatchday = ((Long) singleConfig.get("leagueMatchday")).intValue();
|
||||
apiFootballMatches.addAll(conn.getMatchDataByLeagueAndMatchday(matchesLeague, leagueMatchday));
|
||||
break;
|
||||
case "SingleMatch":
|
||||
int matchLeague = ((Long) singleConfig.get("matchLeague")).intValue();
|
||||
int matchId = ((Long) singleConfig.get("matchId")).intValue();
|
||||
apiFootballMatches.add(conn.getMatchDataByLeagueAndMatchID(matchLeague, matchId));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return apiFootballMatches;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user