void visit(String key, Double val) { entity.setProperty(key, val); }
void visit(String key, Integer val) { entity.setProperty(key, val); }
void visit(String key, Long val) { entity.setProperty(key, val); }
void visit(String key, String val) { entity.setProperty(key, val); }
void visit(String key, JSONObject val) {
EmbeddedEntity embedded = new EmbeddedEntity();
setProperties(embedded, val);
entity.setProperty(key, embedded);
}
void visit(String key, JSONArray val) {
Collection<Object> objs = new ArrayList<Object>(val.length());
for (int i = 0; i < val.length(); i++) {
Object arrVal;
try {
arrVal = val.get(i);
} catch(JSONException e) {
throw new ArrayIndexOutOfBoundsException("" + e);
}
if (arrVal instanceof JSONObject) {
EmbeddedEntity embedded = new EmbeddedEntity();
setProperties(embedded, (JSONObject) arrVal);
objs.add(embedded);
} else {
objs.add(arrVal);
}