Remove Gist
This commit is contained in:
45
src/main/java/de/jeyp91/ResourceProvider.java
Normal file
45
src/main/java/de/jeyp91/ResourceProvider.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package de.jeyp91;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class ResourceProvider {
|
||||
|
||||
private static JSONArray getJSONArrayFromResource(String path) {
|
||||
URL url = Resources.getResource(path);
|
||||
String jsonConfig;
|
||||
JSONArray array = null;
|
||||
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
array = (JSONArray) jsonParser.parse(jsonConfig);
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static JSONArray getLigenConfig() {
|
||||
return getJSONArrayFromResource("Tippliga/Ligen.json");
|
||||
}
|
||||
|
||||
public static JSONArray getTeamIDMatcherConfig() {
|
||||
return getJSONArrayFromResource("Tippliga/Team_ID_Matcher_Config.json");
|
||||
}
|
||||
|
||||
public static JSONArray getTipperMatchPairConfig() {
|
||||
return getJSONArrayFromResource("Tippliga/Tipper_Match_Pair_Config.json");
|
||||
}
|
||||
|
||||
public static JSONArray getTipperTeamConfig() {
|
||||
return getJSONArrayFromResource("Tippliga/Tipper_Team_Config.json");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user