Search in sources :

Example 31 with Row

use of io.realm.internal.Row 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());
}
Also used : RealmObjectProxy(io.realm.internal.RealmObjectProxy) Row(io.realm.internal.Row)

Example 32 with Row

use of io.realm.internal.Row in project realm-java by realm.

the class NullTypesRealmProxy method realmSet$fieldBooleanNotNull.

public void realmSet$fieldBooleanNotNull(Boolean value) {
    if (proxyState.isUnderConstruction()) {
        if (!proxyState.getAcceptDefaultValue$realm()) {
            return;
        }
        final Row row = proxyState.getRow$realm();
        if (value == null) {
            throw new IllegalArgumentException("Trying to set non-nullable field 'fieldBooleanNotNull' to null.");
        }
        row.getTable().setBoolean(columnInfo.fieldBooleanNotNullIndex, row.getIndex(), value, true);
        return;
    }
    proxyState.getRealm$realm().checkIfValid();
    if (value == null) {
        throw new IllegalArgumentException("Trying to set non-nullable field 'fieldBooleanNotNull' to null.");
    }
    proxyState.getRow$realm().setBoolean(columnInfo.fieldBooleanNotNullIndex, value);
}
Also used : Row(io.realm.internal.Row)

Example 33 with Row

use of io.realm.internal.Row in project realm-java by realm.

the class NullTypesRealmProxy method realmSet$fieldBytesNull.

public void realmSet$fieldBytesNull(byte[] value) {
    if (proxyState.isUnderConstruction()) {
        if (!proxyState.getAcceptDefaultValue$realm()) {
            return;
        }
        final Row row = proxyState.getRow$realm();
        if (value == null) {
            row.getTable().setNull(columnInfo.fieldBytesNullIndex, row.getIndex(), true);
            return;
        }
        row.getTable().setBinaryByteArray(columnInfo.fieldBytesNullIndex, row.getIndex(), value, true);
        return;
    }
    proxyState.getRealm$realm().checkIfValid();
    if (value == null) {
        proxyState.getRow$realm().setNull(columnInfo.fieldBytesNullIndex);
        return;
    }
    proxyState.getRow$realm().setBinaryByteArray(columnInfo.fieldBytesNullIndex, value);
}
Also used : Row(io.realm.internal.Row)

Example 34 with Row

use of io.realm.internal.Row in project realm-java by realm.

the class NullTypesRealmProxy method realmSet$fieldDateNull.

public void realmSet$fieldDateNull(Date value) {
    if (proxyState.isUnderConstruction()) {
        if (!proxyState.getAcceptDefaultValue$realm()) {
            return;
        }
        final Row row = proxyState.getRow$realm();
        if (value == null) {
            row.getTable().setNull(columnInfo.fieldDateNullIndex, row.getIndex(), true);
            return;
        }
        row.getTable().setDate(columnInfo.fieldDateNullIndex, row.getIndex(), value, true);
        return;
    }
    proxyState.getRealm$realm().checkIfValid();
    if (value == null) {
        proxyState.getRow$realm().setNull(columnInfo.fieldDateNullIndex);
        return;
    }
    proxyState.getRow$realm().setDate(columnInfo.fieldDateNullIndex, value);
}
Also used : Row(io.realm.internal.Row)

Example 35 with Row

use of io.realm.internal.Row in project realm-java by realm.

the class NullTypesRealmProxy method realmSet$fieldDoubleNotNull.

public void realmSet$fieldDoubleNotNull(Double value) {
    if (proxyState.isUnderConstruction()) {
        if (!proxyState.getAcceptDefaultValue$realm()) {
            return;
        }
        final Row row = proxyState.getRow$realm();
        if (value == null) {
            throw new IllegalArgumentException("Trying to set non-nullable field 'fieldDoubleNotNull' to null.");
        }
        row.getTable().setDouble(columnInfo.fieldDoubleNotNullIndex, row.getIndex(), value, true);
        return;
    }
    proxyState.getRealm$realm().checkIfValid();
    if (value == null) {
        throw new IllegalArgumentException("Trying to set non-nullable field 'fieldDoubleNotNull' to null.");
    }
    proxyState.getRow$realm().setDouble(columnInfo.fieldDoubleNotNullIndex, value);
}
Also used : Row(io.realm.internal.Row)

Aggregations

Row (io.realm.internal.Row)38 RealmObjectProxy (io.realm.internal.RealmObjectProxy)6 InvalidRow (io.realm.internal.InvalidRow)2 UiThreadTest (android.support.test.annotation.UiThreadTest)1 AllTypes (io.realm.entities.AllTypes)1 Collection (io.realm.internal.Collection)1 PendingRow (io.realm.internal.PendingRow)1 Test (org.junit.Test)1