Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package model; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import org.json.simple.JSONArray; import org.json.simple.JSONObject; /** * * @author roman */ public class Config extends BaseModel { public List<String> queries; public String range; public Config() { this.queries = new ArrayList<>(); } public boolean isConfigFill() { if (queries.isEmpty()) { return false; } if (range == null) { range = "500"; } return true; } @Override public void load(JSONObject item) { Iterator it = item.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Object> pair = (Map.Entry) it.next(); String key = pair.getKey(); Object value = pair.getValue(); if (value == null) { continue; } if ("queries".equals(key)) { JSONArray queries = (JSONArray) value; this.loadQueries(queries); continue; } this.setAttribute(key, value.toString()); } } public void loadQueries(JSONArray queries) { Iterator it = queries.iterator(); while (it.hasNext()) { String value = it.next().toString(); this.queries.add(value); } } }