use of io.realm.internal.Table in project realm-java by realm.
the class RealmSchema method getSchemaForClass.
RealmObjectSchema getSchemaForClass(String className) {
className = Table.TABLE_PREFIX + className;
RealmObjectSchema dynamicSchema = dynamicClassToSchema.get(className);
if (dynamicSchema == null) {
if (!realm.sharedRealm.hasTable(className)) {
throw new IllegalArgumentException("The class " + className + " doesn't exist in this Realm.");
}
Table table = realm.sharedRealm.getTable(className);
RealmObjectSchema.DynamicColumnMap columnIndices = new RealmObjectSchema.DynamicColumnMap(table);
dynamicSchema = new RealmObjectSchema(realm, table, columnIndices);
dynamicClassToSchema.put(className, dynamicSchema);
}
return dynamicSchema;
}
use of io.realm.internal.Table in project realm-java by realm.
the class DynamicRealmObject method setObject.
/**
* Sets a reference to another object on the given field.
*
* @param fieldName field name.
* @param value object to link to.
* @throws IllegalArgumentException if field name doesn't exist, it doesn't link to other Realm objects, the type
* of DynamicRealmObject doesn't match or it belongs to a different Realm.
*/
public void setObject(String fieldName, DynamicRealmObject value) {
proxyState.getRealm$realm().checkIfValid();
long columnIndex = proxyState.getRow$realm().getColumnIndex(fieldName);
if (value == null) {
proxyState.getRow$realm().nullifyLink(columnIndex);
} else {
if (value.proxyState.getRealm$realm() == null || value.proxyState.getRow$realm() == null) {
throw new IllegalArgumentException("Cannot link to objects that are not part of the Realm.");
}
if (proxyState.getRealm$realm() != value.proxyState.getRealm$realm()) {
throw new IllegalArgumentException("Cannot add an object from another Realm instance.");
}
Table table = proxyState.getRow$realm().getTable().getLinkTarget(columnIndex);
Table inputTable = value.proxyState.getRow$realm().getTable();
if (!table.hasSameSchema(inputTable)) {
throw new IllegalArgumentException(String.format("Type of object is wrong. Was %s, expected %s", inputTable.getName(), table.getName()));
}
proxyState.getRow$realm().setLink(columnIndex, value.proxyState.getRow$realm().getIndex());
}
}
use of io.realm.internal.Table in project realm-java by realm.
the class NullTypesRealmProxy method validateTable.
public static NullTypesColumnInfo validateTable(SharedRealm sharedRealm, boolean allowExtraColumns) {
if (!sharedRealm.hasTable("class_NullTypes")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "The 'NullTypes' class is missing from the schema for this Realm.");
}
Table table = sharedRealm.getTable("class_NullTypes");
final long columnCount = table.getColumnCount();
if (columnCount != 21) {
if (columnCount < 21) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field count is less than expected - expected 21 but was " + columnCount);
}
if (allowExtraColumns) {
RealmLog.debug("Field count is more than expected - expected 21 but was %1$d", columnCount);
} else {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field count is more than expected - expected 21 but was " + columnCount);
}
}
Map<String, RealmFieldType> columnTypes = new HashMap<String, RealmFieldType>();
for (long i = 0; i < columnCount; i++) {
columnTypes.put(table.getColumnName(i), table.getColumnType(i));
}
final NullTypesColumnInfo columnInfo = new NullTypesColumnInfo(sharedRealm.getPath(), table);
if (table.hasPrimaryKey()) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Primary Key defined for field " + table.getColumnName(table.getPrimaryKey()) + " was removed.");
}
if (!columnTypes.containsKey("fieldStringNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldStringNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldStringNotNull") != RealmFieldType.STRING) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'String' for field 'fieldStringNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldStringNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldStringNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldStringNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldStringNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldStringNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldStringNull") != RealmFieldType.STRING) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'String' for field 'fieldStringNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldStringNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldStringNull' is required. Either set @Required to field 'fieldStringNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldBooleanNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldBooleanNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldBooleanNotNull") != RealmFieldType.BOOLEAN) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Boolean' for field 'fieldBooleanNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldBooleanNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldBooleanNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldBooleanNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldBooleanNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldBooleanNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldBooleanNull") != RealmFieldType.BOOLEAN) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Boolean' for field 'fieldBooleanNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldBooleanNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldBooleanNull' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'fieldBooleanNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldBytesNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldBytesNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldBytesNotNull") != RealmFieldType.BINARY) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'byte[]' for field 'fieldBytesNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldBytesNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldBytesNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldBytesNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldBytesNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldBytesNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldBytesNull") != RealmFieldType.BINARY) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'byte[]' for field 'fieldBytesNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldBytesNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldBytesNull' is required. Either set @Required to field 'fieldBytesNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldByteNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldByteNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldByteNotNull") != RealmFieldType.INTEGER) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Byte' for field 'fieldByteNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldByteNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldByteNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldByteNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldByteNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldByteNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldByteNull") != RealmFieldType.INTEGER) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Byte' for field 'fieldByteNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldByteNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldByteNull' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'fieldByteNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldShortNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldShortNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldShortNotNull") != RealmFieldType.INTEGER) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Short' for field 'fieldShortNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldShortNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldShortNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldShortNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldShortNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldShortNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldShortNull") != RealmFieldType.INTEGER) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Short' for field 'fieldShortNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldShortNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldShortNull' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'fieldShortNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldIntegerNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldIntegerNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldIntegerNotNull") != RealmFieldType.INTEGER) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Integer' for field 'fieldIntegerNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldIntegerNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldIntegerNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldIntegerNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldIntegerNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldIntegerNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldIntegerNull") != RealmFieldType.INTEGER) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Integer' for field 'fieldIntegerNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldIntegerNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldIntegerNull' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'fieldIntegerNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldLongNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldLongNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldLongNotNull") != RealmFieldType.INTEGER) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Long' for field 'fieldLongNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldLongNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldLongNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldLongNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldLongNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldLongNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldLongNull") != RealmFieldType.INTEGER) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Long' for field 'fieldLongNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldLongNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldLongNull' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'fieldLongNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldFloatNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldFloatNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldFloatNotNull") != RealmFieldType.FLOAT) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Float' for field 'fieldFloatNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldFloatNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldFloatNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldFloatNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldFloatNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldFloatNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldFloatNull") != RealmFieldType.FLOAT) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Float' for field 'fieldFloatNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldFloatNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldFloatNull' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'fieldFloatNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldDoubleNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldDoubleNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldDoubleNotNull") != RealmFieldType.DOUBLE) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Double' for field 'fieldDoubleNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldDoubleNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldDoubleNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldDoubleNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldDoubleNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldDoubleNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldDoubleNull") != RealmFieldType.DOUBLE) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Double' for field 'fieldDoubleNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldDoubleNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldDoubleNull' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'fieldDoubleNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldDateNotNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldDateNotNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldDateNotNull") != RealmFieldType.DATE) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Date' for field 'fieldDateNotNull' in existing Realm file.");
}
if (table.isColumnNullable(columnInfo.fieldDateNotNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldDateNotNull' does support null values in the existing Realm file. Remove @Required or @PrimaryKey from field 'fieldDateNotNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldDateNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldDateNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldDateNull") != RealmFieldType.DATE) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'Date' for field 'fieldDateNull' in existing Realm file.");
}
if (!table.isColumnNullable(columnInfo.fieldDateNullIndex)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Field 'fieldDateNull' is required. Either set @Required to field 'fieldDateNull' or migrate using RealmObjectSchema.setNullable().");
}
if (!columnTypes.containsKey("fieldObjectNull")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing field 'fieldObjectNull' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
}
if (columnTypes.get("fieldObjectNull") != RealmFieldType.OBJECT) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid type 'NullTypes' for field 'fieldObjectNull'");
}
if (!sharedRealm.hasTable("class_NullTypes")) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Missing class 'class_NullTypes' for field 'fieldObjectNull'");
}
Table table_20 = sharedRealm.getTable("class_NullTypes");
if (!table.getLinkTarget(columnInfo.fieldObjectNullIndex).hasSameSchema(table_20)) {
throw new RealmMigrationNeededException(sharedRealm.getPath(), "Invalid RealmObject for field 'fieldObjectNull': '" + table.getLinkTarget(columnInfo.fieldObjectNullIndex).getName() + "' expected - was '" + table_20.getName() + "'");
}
return columnInfo;
}
use of io.realm.internal.Table in project realm-java by realm.
the class NullTypesRealmProxy method insertOrUpdate.
public static void insertOrUpdate(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);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldStringNotNullIndex, rowIndex, false);
}
String realmGet$fieldStringNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldStringNull();
if (realmGet$fieldStringNull != null) {
Table.nativeSetString(tableNativePtr, columnInfo.fieldStringNullIndex, rowIndex, realmGet$fieldStringNull, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldStringNullIndex, rowIndex, false);
}
Boolean realmGet$fieldBooleanNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldBooleanNotNull();
if (realmGet$fieldBooleanNotNull != null) {
Table.nativeSetBoolean(tableNativePtr, columnInfo.fieldBooleanNotNullIndex, rowIndex, realmGet$fieldBooleanNotNull, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldBooleanNotNullIndex, rowIndex, false);
}
Boolean realmGet$fieldBooleanNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldBooleanNull();
if (realmGet$fieldBooleanNull != null) {
Table.nativeSetBoolean(tableNativePtr, columnInfo.fieldBooleanNullIndex, rowIndex, realmGet$fieldBooleanNull, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldBooleanNullIndex, rowIndex, false);
}
byte[] realmGet$fieldBytesNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldBytesNotNull();
if (realmGet$fieldBytesNotNull != null) {
Table.nativeSetByteArray(tableNativePtr, columnInfo.fieldBytesNotNullIndex, rowIndex, realmGet$fieldBytesNotNull, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldBytesNotNullIndex, rowIndex, false);
}
byte[] realmGet$fieldBytesNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldBytesNull();
if (realmGet$fieldBytesNull != null) {
Table.nativeSetByteArray(tableNativePtr, columnInfo.fieldBytesNullIndex, rowIndex, realmGet$fieldBytesNull, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldBytesNullIndex, rowIndex, false);
}
Number realmGet$fieldByteNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldByteNotNull();
if (realmGet$fieldByteNotNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldByteNotNullIndex, rowIndex, realmGet$fieldByteNotNull.longValue(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldByteNotNullIndex, rowIndex, false);
}
Number realmGet$fieldByteNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldByteNull();
if (realmGet$fieldByteNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldByteNullIndex, rowIndex, realmGet$fieldByteNull.longValue(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldByteNullIndex, rowIndex, false);
}
Number realmGet$fieldShortNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldShortNotNull();
if (realmGet$fieldShortNotNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldShortNotNullIndex, rowIndex, realmGet$fieldShortNotNull.longValue(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldShortNotNullIndex, rowIndex, false);
}
Number realmGet$fieldShortNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldShortNull();
if (realmGet$fieldShortNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldShortNullIndex, rowIndex, realmGet$fieldShortNull.longValue(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldShortNullIndex, rowIndex, false);
}
Number realmGet$fieldIntegerNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldIntegerNotNull();
if (realmGet$fieldIntegerNotNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldIntegerNotNullIndex, rowIndex, realmGet$fieldIntegerNotNull.longValue(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldIntegerNotNullIndex, rowIndex, false);
}
Number realmGet$fieldIntegerNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldIntegerNull();
if (realmGet$fieldIntegerNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldIntegerNullIndex, rowIndex, realmGet$fieldIntegerNull.longValue(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldIntegerNullIndex, rowIndex, false);
}
Number realmGet$fieldLongNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldLongNotNull();
if (realmGet$fieldLongNotNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldLongNotNullIndex, rowIndex, realmGet$fieldLongNotNull.longValue(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldLongNotNullIndex, rowIndex, false);
}
Number realmGet$fieldLongNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldLongNull();
if (realmGet$fieldLongNull != null) {
Table.nativeSetLong(tableNativePtr, columnInfo.fieldLongNullIndex, rowIndex, realmGet$fieldLongNull.longValue(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldLongNullIndex, rowIndex, false);
}
Float realmGet$fieldFloatNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldFloatNotNull();
if (realmGet$fieldFloatNotNull != null) {
Table.nativeSetFloat(tableNativePtr, columnInfo.fieldFloatNotNullIndex, rowIndex, realmGet$fieldFloatNotNull, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldFloatNotNullIndex, rowIndex, false);
}
Float realmGet$fieldFloatNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldFloatNull();
if (realmGet$fieldFloatNull != null) {
Table.nativeSetFloat(tableNativePtr, columnInfo.fieldFloatNullIndex, rowIndex, realmGet$fieldFloatNull, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldFloatNullIndex, rowIndex, false);
}
Double realmGet$fieldDoubleNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldDoubleNotNull();
if (realmGet$fieldDoubleNotNull != null) {
Table.nativeSetDouble(tableNativePtr, columnInfo.fieldDoubleNotNullIndex, rowIndex, realmGet$fieldDoubleNotNull, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldDoubleNotNullIndex, rowIndex, false);
}
Double realmGet$fieldDoubleNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldDoubleNull();
if (realmGet$fieldDoubleNull != null) {
Table.nativeSetDouble(tableNativePtr, columnInfo.fieldDoubleNullIndex, rowIndex, realmGet$fieldDoubleNull, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldDoubleNullIndex, rowIndex, false);
}
java.util.Date realmGet$fieldDateNotNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldDateNotNull();
if (realmGet$fieldDateNotNull != null) {
Table.nativeSetTimestamp(tableNativePtr, columnInfo.fieldDateNotNullIndex, rowIndex, realmGet$fieldDateNotNull.getTime(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldDateNotNullIndex, rowIndex, false);
}
java.util.Date realmGet$fieldDateNull = ((NullTypesRealmProxyInterface) object).realmGet$fieldDateNull();
if (realmGet$fieldDateNull != null) {
Table.nativeSetTimestamp(tableNativePtr, columnInfo.fieldDateNullIndex, rowIndex, realmGet$fieldDateNull.getTime(), false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.fieldDateNullIndex, rowIndex, false);
}
some.test.NullTypes fieldObjectNullObj = ((NullTypesRealmProxyInterface) object).realmGet$fieldObjectNull();
if (fieldObjectNullObj != null) {
Long cachefieldObjectNull = cache.get(fieldObjectNullObj);
if (cachefieldObjectNull == null) {
cachefieldObjectNull = NullTypesRealmProxy.insertOrUpdate(realm, fieldObjectNullObj, cache);
}
Table.nativeSetLink(tableNativePtr, columnInfo.fieldObjectNullIndex, rowIndex, cachefieldObjectNull, false);
} else {
Table.nativeNullifyLink(tableNativePtr, columnInfo.fieldObjectNullIndex, rowIndex);
}
}
}
}
use of io.realm.internal.Table in project realm-java by realm.
the class BooleansRealmProxy method insertOrUpdate.
public static void insertOrUpdate(Realm realm, Iterator<? extends RealmModel> objects, Map<RealmModel, Long> cache) {
Table table = realm.getTable(some.test.Booleans.class);
long tableNativePtr = table.getNativeTablePointer();
BooleansColumnInfo columnInfo = (BooleansColumnInfo) realm.schema.getColumnInfo(some.test.Booleans.class);
some.test.Booleans object = null;
while (objects.hasNext()) {
object = (some.test.Booleans) 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);
Table.nativeSetBoolean(tableNativePtr, columnInfo.doneIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$done(), false);
Table.nativeSetBoolean(tableNativePtr, columnInfo.isReadyIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$isReady(), false);
Table.nativeSetBoolean(tableNativePtr, columnInfo.mCompletedIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$mCompleted(), false);
Table.nativeSetBoolean(tableNativePtr, columnInfo.anotherBooleanIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$anotherBoolean(), false);
}
}
}
Aggregations