private <MODEL> MODEL innerGetModel(Class<MODEL> modelClass, String fileName) { fileName = fileName + ".json"; ClassLoader classLoader = getClass().getClassLoader(); InputStream inputStream = classLoader.getResourceAsStream(fileName); Gson gson = HttpModule.getGson(); return gson.fromJson(new BufferedReader(new InputStreamReader(inputStream)), modelClass); }
private <MODEL> List<MODEL> innerGetModelList(Class<MODEL> modelClass, String fileName) { fileName = fileName + ".json"; ClassLoader classLoader = getClass().getClassLoader(); InputStream inputStream = classLoader.getResourceAsStream(fileName); Gson gson = HttpModule.getGson(); List<MODEL> output = new ArrayList<>(); JsonArray fileData = gson.fromJson(new BufferedReader(new InputStreamReader(inputStream)), JsonArray.class); for (int i = 0; i < fileData.size(); i++) { output.add(gson.fromJson(fileData.get(i), modelClass)); } return output; }