public void persistVehicleTypes() { persistIncidents(); JSONArray jsonVehicleTypes = new JSONArray(); for (VehicleType vehicleType : vehicleTypes) { jsonVehicleTypes.add(vehicleType.jsonify()); } json.put("vehicleTypes", jsonVehicleTypes); }
public VehicleType getVehicleType(int id) { for (VehicleType type : vehicleTypes) { if (type.getId() == id) { return type; } } return null; }
private void restoreVehicleTypes() { JSONArray jsonVehicleTypes = (JSONArray) json.get("vehicleTypes"); int size = jsonVehicleTypes.size(); for (int i = 0; i < size; ++i) { JSONObject jsonVehicleType = (JSONObject) jsonVehicleTypes.get(i); VehicleType vehicleType = VehicleType.createFromJSON(jsonVehicleType); vehicleTypes.add(vehicleType); } }