コード例 #1
0
 public static some.test.Simple createDetachedCopy(
     some.test.Simple realmObject,
     int currentDepth,
     int maxDepth,
     Map<RealmModel, CacheData<RealmModel>> cache) {
   if (currentDepth > maxDepth || realmObject == null) {
     return null;
   }
   CacheData<RealmModel> cachedObject = cache.get(realmObject);
   some.test.Simple unmanagedObject;
   if (cachedObject != null) {
     // Reuse cached object or recreate it because it was encountered at a lower depth.
     if (currentDepth >= cachedObject.minDepth) {
       return (some.test.Simple) cachedObject.object;
     } else {
       unmanagedObject = (some.test.Simple) cachedObject.object;
       cachedObject.minDepth = currentDepth;
     }
   } else {
     unmanagedObject = new some.test.Simple();
     cache.put(realmObject, new RealmObjectProxy.CacheData(currentDepth, unmanagedObject));
   }
   ((SimpleRealmProxyInterface) unmanagedObject)
       .realmSet$name(((SimpleRealmProxyInterface) realmObject).realmGet$name());
   ((SimpleRealmProxyInterface) unmanagedObject)
       .realmSet$age(((SimpleRealmProxyInterface) realmObject).realmGet$age());
   return unmanagedObject;
 }
コード例 #2
0
 @SuppressWarnings("cast")
 public static some.test.Simple createUsingJsonStream(Realm realm, JsonReader reader)
     throws IOException {
   some.test.Simple obj = realm.createObject(some.test.Simple.class);
   reader.beginObject();
   while (reader.hasNext()) {
     String name = reader.nextName();
     if (name.equals("name")) {
       if (reader.peek() == JsonToken.NULL) {
         reader.skipValue();
         ((SimpleRealmProxyInterface) obj).realmSet$name(null);
       } else {
         ((SimpleRealmProxyInterface) obj).realmSet$name((String) reader.nextString());
       }
     } else if (name.equals("age")) {
       if (reader.peek() == JsonToken.NULL) {
         reader.skipValue();
         throw new IllegalArgumentException("Trying to set non-nullable field 'age' to null.");
       } else {
         ((SimpleRealmProxyInterface) obj).realmSet$age((int) reader.nextInt());
       }
     } else {
       reader.skipValue();
     }
   }
   reader.endObject();
   return obj;
 }
コード例 #3
0
 public static some.test.Simple copy(
     Realm realm,
     some.test.Simple newObject,
     boolean update,
     Map<RealmModel, RealmObjectProxy> cache) {
   RealmObjectProxy cachedRealmObject = cache.get(newObject);
   if (cachedRealmObject != null) {
     return (some.test.Simple) cachedRealmObject;
   } else {
     some.test.Simple realmObject = realm.createObject(some.test.Simple.class);
     cache.put(newObject, (RealmObjectProxy) realmObject);
     ((SimpleRealmProxyInterface) realmObject)
         .realmSet$name(((SimpleRealmProxyInterface) newObject).realmGet$name());
     ((SimpleRealmProxyInterface) realmObject)
         .realmSet$age(((SimpleRealmProxyInterface) newObject).realmGet$age());
     return realmObject;
   }
 }
コード例 #4
0
 @SuppressWarnings("cast")
 public static some.test.Simple createOrUpdateUsingJsonObject(
     Realm realm, JSONObject json, boolean update) throws JSONException {
   some.test.Simple obj = realm.createObject(some.test.Simple.class);
   if (json.has("name")) {
     if (json.isNull("name")) {
       ((SimpleRealmProxyInterface) obj).realmSet$name(null);
     } else {
       ((SimpleRealmProxyInterface) obj).realmSet$name((String) json.getString("name"));
     }
   }
   if (json.has("age")) {
     if (json.isNull("age")) {
       throw new IllegalArgumentException("Trying to set non-nullable field 'age' to null.");
     } else {
       ((SimpleRealmProxyInterface) obj).realmSet$age((int) json.getInt("age"));
     }
   }
   return obj;
 }