public void persistReporters() { JSONArray jsonReporters = new JSONArray(); for (Reporter reporter : reporters) { jsonReporters.add(reporter.jsonify()); } json.put("reporters", jsonReporters); }
public Reporter getReporter(String firstName, String lastName) { for (Reporter reporter : reporters) { if (reporter.getFirstName() == firstName && reporter.getLastName() == lastName) { return reporter; } } return null; }
public Reporter getReporter(int id) { for (Reporter reporter : reporters) { if (reporter.getId() == id) { return reporter; } } return null; }
private void restoreReporters() { JSONArray jsonReporters = (JSONArray) json.get("reporters"); int size = jsonReporters.size(); for (int i = 0; i < size; ++i) { JSONObject jsonReporter = (JSONObject) jsonReporters.get(i); Reporter reporter = Reporter.createFromJSON(jsonReporter); reporters.add(reporter); } }