public static SatsClass createUsingJsonStream(Realm realm, JsonReader reader) throws IOException { SatsClass obj = realm.createObject(SatsClass.class); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("id") && reader.peek() != JsonToken.NULL) { obj.setId((String) reader.nextString()); } else if (name.equals("centerFilterId") && reader.peek() != JsonToken.NULL) { obj.setCenterFilterId((String) reader.nextString()); } else if (name.equals("classTypeId") && reader.peek() != JsonToken.NULL) { obj.setClassTypeId((String) reader.nextString()); } else if (name.equals("durationInMinutes") && reader.peek() != JsonToken.NULL) { obj.setDurationInMinutes((int) reader.nextInt()); } else if (name.equals("instructorId") && reader.peek() != JsonToken.NULL) { obj.setInstructorId((String) reader.nextString()); } else if (name.equals("name") && reader.peek() != JsonToken.NULL) { obj.setName((String) reader.nextString()); } else if (name.equals("startTime") && reader.peek() != JsonToken.NULL) { obj.setStartTime((String) reader.nextString()); } else if (name.equals("bookedPersonsCount") && reader.peek() != JsonToken.NULL) { obj.setBookedPersonsCount((int) reader.nextInt()); } else if (name.equals("maxPersonsCount") && reader.peek() != JsonToken.NULL) { obj.setMaxPersonsCount((int) reader.nextInt()); } else if (name.equals("regionId") && reader.peek() != JsonToken.NULL) { obj.setRegionId((String) reader.nextString()); } else if (name.equals("waitingListCount") && reader.peek() != JsonToken.NULL) { obj.setWaitingListCount((int) reader.nextInt()); } else if (name.equals("classCategoryIds") && reader.peek() != JsonToken.NULL) { reader.beginArray(); while (reader.hasNext()) { se.greatbrain.sats.data.model.ClassCategoryIds item = ClassCategoryIdsRealmProxy.createUsingJsonStream(realm, reader); obj.getClassCategoryIds().add(item); } reader.endArray(); } else { reader.skipValue(); } } reader.endObject(); return obj; }
public static SatsClass copy( Realm realm, SatsClass newObject, boolean update, Map<RealmObject, RealmObject> cache) { SatsClass realmObject = realm.createObject(SatsClass.class, newObject.getId()); cache.put(newObject, realmObject); realmObject.setId(newObject.getId() != null ? newObject.getId() : ""); realmObject.setCenterFilterId( newObject.getCenterFilterId() != null ? newObject.getCenterFilterId() : ""); realmObject.setClassTypeId( newObject.getClassTypeId() != null ? newObject.getClassTypeId() : ""); realmObject.setDurationInMinutes(newObject.getDurationInMinutes()); realmObject.setInstructorId( newObject.getInstructorId() != null ? newObject.getInstructorId() : ""); realmObject.setName(newObject.getName() != null ? newObject.getName() : ""); realmObject.setStartTime(newObject.getStartTime() != null ? newObject.getStartTime() : ""); realmObject.setBookedPersonsCount(newObject.getBookedPersonsCount()); realmObject.setMaxPersonsCount(newObject.getMaxPersonsCount()); realmObject.setRegionId(newObject.getRegionId() != null ? newObject.getRegionId() : ""); realmObject.setWaitingListCount(newObject.getWaitingListCount()); RealmList<ClassCategoryIds> classCategoryIdsList = newObject.getClassCategoryIds(); if (classCategoryIdsList != null) { RealmList<ClassCategoryIds> classCategoryIdsRealmList = realmObject.getClassCategoryIds(); for (int i = 0; i < classCategoryIdsList.size(); i++) { ClassCategoryIds classCategoryIdsItem = classCategoryIdsList.get(i); ClassCategoryIds cacheclassCategoryIds = (ClassCategoryIds) cache.get(classCategoryIdsItem); if (cacheclassCategoryIds != null) { classCategoryIdsRealmList.add(cacheclassCategoryIds); } else { classCategoryIdsRealmList.add( ClassCategoryIdsRealmProxy.copyOrUpdate( realm, classCategoryIdsList.get(i), update, cache)); } } } return realmObject; }
public static SatsClass createOrUpdateUsingJsonObject( Realm realm, JSONObject json, boolean update) throws JSONException { SatsClass obj = null; if (update) { Table table = realm.getTable(SatsClass.class); long pkColumnIndex = table.getPrimaryKey(); if (!json.isNull("id")) { long rowIndex = table.findFirstString(pkColumnIndex, json.getString("id")); if (rowIndex != TableOrView.NO_MATCH) { obj = new SatsClassRealmProxy(); obj.realm = realm; obj.row = table.getRow(rowIndex); } } } if (obj == null) { obj = realm.createObject(SatsClass.class); } if (!json.isNull("id")) { obj.setId((String) json.getString("id")); } if (!json.isNull("centerFilterId")) { obj.setCenterFilterId((String) json.getString("centerFilterId")); } if (!json.isNull("classTypeId")) { obj.setClassTypeId((String) json.getString("classTypeId")); } if (!json.isNull("durationInMinutes")) { obj.setDurationInMinutes((int) json.getInt("durationInMinutes")); } if (!json.isNull("instructorId")) { obj.setInstructorId((String) json.getString("instructorId")); } if (!json.isNull("name")) { obj.setName((String) json.getString("name")); } if (!json.isNull("startTime")) { obj.setStartTime((String) json.getString("startTime")); } if (!json.isNull("bookedPersonsCount")) { obj.setBookedPersonsCount((int) json.getInt("bookedPersonsCount")); } if (!json.isNull("maxPersonsCount")) { obj.setMaxPersonsCount((int) json.getInt("maxPersonsCount")); } if (!json.isNull("regionId")) { obj.setRegionId((String) json.getString("regionId")); } if (!json.isNull("waitingListCount")) { obj.setWaitingListCount((int) json.getInt("waitingListCount")); } if (!json.isNull("classCategoryIds")) { obj.getClassCategoryIds().clear(); JSONArray array = json.getJSONArray("classCategoryIds"); for (int i = 0; i < array.length(); i++) { se.greatbrain.sats.data.model.ClassCategoryIds item = ClassCategoryIdsRealmProxy.createOrUpdateUsingJsonObject( realm, array.getJSONObject(i), update); obj.getClassCategoryIds().add(item); } } return obj; }