use of io.realm.internal.RealmObjectProxy in project realm-java by realm.
the class SimpleRealmProxy method insert.
public static void insert(Realm realm, Iterator<? extends RealmModel> objects, Map<RealmModel, Long> cache) {
Table table = realm.getTable(some.test.Simple.class);
long tableNativePtr = table.getNativeTablePointer();
SimpleColumnInfo columnInfo = (SimpleColumnInfo) realm.schema.getColumnInfo(some.test.Simple.class);
some.test.Simple object = null;
while (objects.hasNext()) {
object = (some.test.Simple) objects.next();
if (!cache.containsKey(object)) {
if (object instanceof RealmObjectProxy && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm() != null && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm().getPath().equals(realm.getPath())) {
cache.put(object, ((RealmObjectProxy) object).realmGet$proxyState().getRow$realm().getIndex());
continue;
}
long rowIndex = Table.nativeAddEmptyRow(tableNativePtr, 1);
cache.put(object, rowIndex);
String realmGet$name = ((SimpleRealmProxyInterface) object).realmGet$name();
if (realmGet$name != null) {
Table.nativeSetString(tableNativePtr, columnInfo.nameIndex, rowIndex, realmGet$name, false);
}
Table.nativeSetLong(tableNativePtr, columnInfo.ageIndex, rowIndex, ((SimpleRealmProxyInterface) object).realmGet$age(), false);
}
}
}
use of io.realm.internal.RealmObjectProxy in project realm-java by realm.
the class NullTypesRealmProxy method realmSet$fieldObjectNull.
public void realmSet$fieldObjectNull(some.test.NullTypes value) {
if (proxyState.isUnderConstruction()) {
if (!proxyState.getAcceptDefaultValue$realm()) {
return;
}
if (proxyState.getExcludeFields$realm().contains("fieldObjectNull")) {
return;
}
if (value != null && !RealmObject.isManaged(value)) {
value = ((Realm) proxyState.getRealm$realm()).copyToRealm(value);
}
final Row row = proxyState.getRow$realm();
if (value == null) {
// Table#nullifyLink() does not support default value. Just using Row.
row.nullifyLink(columnInfo.fieldObjectNullIndex);
return;
}
if (!RealmObject.isValid(value)) {
throw new IllegalArgumentException("'value' is not a valid managed object.");
}
if (((RealmObjectProxy) value).realmGet$proxyState().getRealm$realm() != proxyState.getRealm$realm()) {
throw new IllegalArgumentException("'value' belongs to a different Realm.");
}
row.getTable().setLink(columnInfo.fieldObjectNullIndex, row.getIndex(), ((RealmObjectProxy) value).realmGet$proxyState().getRow$realm().getIndex(), true);
return;
}
proxyState.getRealm$realm().checkIfValid();
if (value == null) {
proxyState.getRow$realm().nullifyLink(columnInfo.fieldObjectNullIndex);
return;
}
if (!(RealmObject.isManaged(value) && RealmObject.isValid(value))) {
throw new IllegalArgumentException("'value' is not a valid managed object.");
}
if (((RealmObjectProxy) value).realmGet$proxyState().getRealm$realm() != proxyState.getRealm$realm()) {
throw new IllegalArgumentException("'value' belongs to a different Realm.");
}
proxyState.getRow$realm().setLink(columnInfo.fieldObjectNullIndex, ((RealmObjectProxy) value).realmGet$proxyState().getRow$realm().getIndex());
}
use of io.realm.internal.RealmObjectProxy in project realm-java by realm.
the class NullTypesRealmProxy method insert.
public static void insert(Realm realm, Iterator<? extends RealmModel> objects, Map<RealmModel, Long> cache) {
Table table = realm.getTable(some.test.NullTypes.class);
long tableNativePtr = table.getNativeTablePointer();
NullTypesColumnInfo columnInfo = (NullTypesColumnInfo) realm.schema.getColumnInfo(some.test.NullTypes.class);
some.test.NullTypes object = null;
while (objects.hasNext()) {
object = (some.test.NullTypes) objects.next();
if (!cache.containsKey(object)) {
if (object instanceof RealmObjectProxy && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm() != null && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm().getPath().equals(realm.getPath())) {
cache.put(object, ((RealmObjectProxy) object).realmGet$proxyState().getRow$realm().getIndex());
continue;
}
long rowIndex = Table.nativeAddEmptyRow(tableNativePtr, 1);
cache.put(object, rowIndex);
String realmGet$fieldStringNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldStringNotNull();
if (realmGet$fieldStringNotNull != null) {
Table.nativeSetString(tableNativePtr, columnInfo.fieldStringNotNullIndex, rowIndex, realmGet$fieldStringNotNull, false);
}
String realmGet$fieldStringNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldStringNull();
if (realmGet$fieldStringNull != null) {
Table.nativeSetString(tableNativePtr, columnInfo.fieldStringNullIndex, rowIndex, realmGet$fieldStringNull, false);
}
Boolean realmGet$fieldBooleanNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldBooleanNotNull();
if (realmGet$fieldBooleanNotNull != null) {
Table.nativeSetBoolean(tableNativePtr, columnInfo.fieldBooleanNotNullIndex, rowIndex, realmGet$fieldBooleanNotNull, false);
}
Boolean realmGet$fieldBooleanNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldBooleanNull();
if (realmGet$fieldBooleanNull != null) {
Table.nativeSetBoolean(tableNativePtr, columnInfo.fieldBooleanNullIndex, rowIndex, realmGet$fieldBooleanNull, false);
}
byte[] realmGet$fieldBytesNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldBytesNotNull();
if (realmGet$fieldBytesNotNull != null) {
Table.nativeSetByteArray(tableNativePtr, columnInfo.fieldBytesNotNullIndex, rowIndex, realmGet$fieldBytesNotNull, false);
}
byte[] realmGet$fieldBytesNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldBytesNull();
if (realmGet$fieldBytesNull != null) {
Table.nativeSetByteArray(tableNativePtr, columnInfo.fieldBytesNullIndex, rowIndex, realmGet$fieldBytesNull, false);
}
Number realmGet$fieldByteNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldByteNotNull();
if (realmGet$fieldByteNotNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldByteNotNullIndex, rowIndex, realmGet$fieldByteNotNull.longValue(), false);
}
Number realmGet$fieldByteNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldByteNull();
if (realmGet$fieldByteNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldByteNullIndex, rowIndex, realmGet$fieldByteNull.longValue(), false);
}
Number realmGet$fieldShortNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldShortNotNull();
if (realmGet$fieldShortNotNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldShortNotNullIndex, rowIndex, realmGet$fieldShortNotNull.longValue(), false);
}
Number realmGet$fieldShortNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldShortNull();
if (realmGet$fieldShortNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldShortNullIndex, rowIndex, realmGet$fieldShortNull.longValue(), false);
}
Number realmGet$fieldIntegerNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldIntegerNotNull();
if (realmGet$fieldIntegerNotNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldIntegerNotNullIndex, rowIndex, realmGet$fieldIntegerNotNull.longValue(), false);
}
Number realmGet$fieldIntegerNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldIntegerNull();
if (realmGet$fieldIntegerNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldIntegerNullIndex, rowIndex, realmGet$fieldIntegerNull.longValue(), false);
}
Number realmGet$fieldLongNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldLongNotNull();
if (realmGet$fieldLongNotNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldLongNotNullIndex, rowIndex, realmGet$fieldLongNotNull.longValue(), false);
}
Number realmGet$fieldLongNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldLongNull();
if (realmGet$fieldLongNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldLongNullIndex, rowIndex, realmGet$fieldLongNull.longValue(), false);
}
Float realmGet$fieldFloatNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldFloatNotNull();
if (realmGet$fieldFloatNotNull != null) {
Table.nativeSetFloat(tableNativePtr, columnInfo.fieldFloatNotNullIndex, rowIndex, realmGet$fieldFloatNotNull, false);
}
Float realmGet$fieldFloatNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldFloatNull();
if (realmGet$fieldFloatNull != null) {
Table.nativeSetFloat(tableNativePtr, columnInfo.fieldFloatNullIndex, rowIndex, realmGet$fieldFloatNull, false);
}
Double realmGet$fieldDoubleNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldDoubleNotNull();
if (realmGet$fieldDoubleNotNull != null) {
Table.nativeSetDouble(tableNativePtr, columnInfo.fieldDoubleNotNullIndex, rowIndex, realmGet$fieldDoubleNotNull, false);
}
Double realmGet$fieldDoubleNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldDoubleNull();
if (realmGet$fieldDoubleNull != null) {
Table.nativeSetDouble(tableNativePtr, columnInfo.fieldDoubleNullIndex, rowIndex, realmGet$fieldDoubleNull, false);
}
java.util.Date realmGet$fieldDateNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldDateNotNull();
if (realmGet$fieldDateNotNull != null) {
Table.nativeSetTimestamp(tableNativePtr, columnInfo.fieldDateNotNullIndex, rowIndex, realmGet$fieldDateNotNull.getTime(), false);
}
java.util.Date realmGet$fieldDateNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldDateNull();
if (realmGet$fieldDateNull != null) {
Table.nativeSetTimestamp(tableNativePtr, columnInfo.fieldDateNullIndex, rowIndex, realmGet$fieldDateNull.getTime(), false);
}
some.test.NullTypes fieldObjectNullObj = ((NullTypesRealmProxyInterface) object).realmGet$fieldObjectNull();
if (fieldObjectNullObj != null) {
Long cachefieldObjectNull = cache.get(fieldObjectNullObj);
if (cachefieldObjectNull == null) {
cachefieldObjectNull = NullTypesRealmProxy.insert(realm, fieldObjectNullObj, cache);
}
table.setLink(columnInfo.fieldObjectNullIndex, rowIndex, cachefieldObjectNull, false);
}
}
}
}
Aggregations