Refactor Line separator for Mac and add APIFootballProvider

This commit is contained in:
Julian Arndt
2020-09-29 17:43:05 +02:00
parent a484010285
commit 9c88c28151
10 changed files with 161 additions and 138 deletions

View File

@@ -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;
}
}