示例#1
0
 @SuppressWarnings("unchecked")
 public void setNativeObject(T o) throws Exception {
   this.nativeObject = o;
   if (parentAnObject != null) {
     parentAnObject.setNativeObject(o);
   }
 }
示例#2
0
 @Override
 public AnAttrib getAttrib(String propertyName) {
   AnAttrib a = attribMap.get(propertyName);
   if (a == null && parentAnObject != null) {
     a = parentAnObject.getAttrib(propertyName);
   }
   return a;
 }
示例#3
0
 @SuppressWarnings("unchecked")
 public void setNativeClass(Class<T> anObjClass) {
   this.nativeClass = anObjClass;
   Class<?> superClass = anObjClass.getSuperclass();
   if (superClass != null) {
     if (parentAnObject != null) {
       parentAnObject.setNativeClass(superClass);
     }
   }
 }
示例#4
0
 @Override
 @SuppressWarnings("unchecked")
 public Map<String, AnAttrib> getAllAttribMap() {
   Map<String, AnAttrib> p = new HashMap<>();
   if (parentAnObject != null) {
     p.putAll(parentAnObject.getAllAttribMap());
   }
   if (attribMap != null) {
     p.putAll(attribMap);
   }
   return p;
 }
示例#5
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;
 }
示例#6
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;
 }
示例#7
0
 @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;
 }