@Override public synchronized T asNativeObject(JSONObject jsonObject) throws Exception { if (nativeObject == null) { resetNativeObject(); } if (parentAnObject != null) { parentAnObject.asNativeObject(jsonObject); } Set<String> attrObjsKeys = attribMap.keySet(); for (String attribName : attrObjsKeys) { AnAttrib attr = attribMap.get(attribName); if (!jsonObject.isNull(attr.getJsonOrAttribName())) { Object attrValue = jsonObject.get(attr.getJsonOrAttribName()); if (attrValue != null) { attr.setValue(attrValue); } } } return nativeObject; }
@Override public Map<String, Object> getJsonMap() throws Exception { if (jsonMap == null) { jsonMap = new HashMap<>(); Set<String> p = attribMap.keySet(); for (String attrName : p) { AnAttrib attr = attribMap.get(attrName); Object value = attr.getValue(); if (value != null) { jsonMap.put(attr.getJsonOrAttribName(), attr.getValue()); } } } if (parentAnObject != null) { @SuppressWarnings("unchecked") Map<String, Object> parentJsonMap = parentAnObject.getJsonMap(); Set<String> keys = parentJsonMap.keySet(); for (String k : keys) { jsonMap.put(k, parentJsonMap.get(k)); } } return jsonMap; }
@Override public synchronized Map<String, Object> asMap(T nativeObject) throws Exception { setNativeObject(nativeObject); if (nativeObjectMap == null) { nativeObjectMap = new HashMap<>(); Set<String> p = attribMap.keySet(); for (String pName : p) { AnAttrib pm = attribMap.get(pName); Object value = pm.getValue(); if (value != null) { nativeObjectMap.put(pName, pm.getValue()); } } } if (parentAnObject != null) { @SuppressWarnings("unchecked") Map<String, Object> parentMap = parentAnObject.asMap(nativeObject); Set<String> keys = parentMap.keySet(); for (String k : keys) { nativeObjectMap.put(k, parentMap.get(k)); } } return nativeObjectMap; }
@Override public void addAttrib(AnAttrib anAttribMapper) { anAttribMapper.setAnObject(this); attribMap.put(anAttribMapper.getAttribName(), anAttribMapper); }