Пример #1
0
 @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;
 }
Пример #2
0
 @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;
 }