uk.gov.service.notify.TemplateList Maven / Gradle / Ivy
package uk.gov.service.notify;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class TemplateList {
private final List templates;
public TemplateList(String content){
JSONObject data = new JSONObject(content);
templates = new ArrayList<>();
JSONArray templatesData = data.getJSONArray("templates");
for(int i = 0; i < templatesData.length(); i++){
JSONObject template = templatesData.getJSONObject(i);
templates.add(new Template(template));
}
}
public List getTemplates() {
return templates;
}
@Override
public String toString() {
return "TemplateList{" +
"templates=" + templates +
'}';
}
}