Search in sources :

Example 1 with UncheckedRow

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

the class BaseRealm method get.

<E extends RealmModel> E get(Class<E> clazz, long rowIndex, boolean acceptDefaultValue, List<String> excludeFields) {
    Table table = schema.getTable(clazz);
    UncheckedRow row = table.getUncheckedRow(rowIndex);
    E result = configuration.getSchemaMediator().newInstance(clazz, this, row, schema.getColumnInfo(clazz), acceptDefaultValue, excludeFields);
    RealmObjectProxy proxy = (RealmObjectProxy) result;
    proxy.realmGet$proxyState().setTableVersion$realm();
    return result;
}
Also used : RealmObjectProxy(io.realm.internal.RealmObjectProxy) Table(io.realm.internal.Table) UncheckedRow(io.realm.internal.UncheckedRow)

Example 2 with UncheckedRow

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

the class OrderedRealmCollectionSnapshot method deleteLastFromRealm.

/**
     * Deletes the last object from the Realm. The last object will become invalid.
     *
     * @return {@code true} if an object was deleted, {@code false} otherwise.
     * @throws java.lang.IllegalStateException if the Realm is closed or the method is called from the wrong thread.
     */
@Override
public boolean deleteLastFromRealm() {
    realm.checkIfValidAndInTransaction();
    UncheckedRow row = collection.lastUncheckedRow();
    return row != null && row.isAttached() && collection.deleteLast();
}
Also used : UncheckedRow(io.realm.internal.UncheckedRow)

Example 3 with UncheckedRow

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

the class OrderedRealmCollectionSnapshot method deleteFirstFromRealm.

/**
     * Deletes the first object from the Realm. The first object will become invalid.
     *
     * @return {@code true} if an object was deleted, {@code false} otherwise.
     * @throws java.lang.IllegalStateException if the Realm is closed or the method is called on the wrong thread.
     */
@Override
public boolean deleteFirstFromRealm() {
    realm.checkIfValidAndInTransaction();
    UncheckedRow row = collection.firstUncheckedRow();
    return row != null && row.isAttached() && collection.deleteFirst();
}
Also used : UncheckedRow(io.realm.internal.UncheckedRow)

Example 4 with UncheckedRow

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

the class OrderedRealmCollectionSnapshot method deleteFromRealm.

/**
     * Deletes the object at the given index from the Realm. The object at the given index will become invalid. Just
     * returns if the object is invalid already.
     *
     * @param location the array index identifying the object to be removed.
     * @throws IndexOutOfBoundsException if {@code location < 0 || location >= size()}.
     * @throws java.lang.IllegalStateException if the Realm is closed or the method is called from the wrong thread.
     */
@Override
public void deleteFromRealm(int location) {
    realm.checkIfValidAndInTransaction();
    UncheckedRow row = collection.getUncheckedRow(location);
    if (row.isAttached()) {
        collection.delete(location);
    }
}
Also used : UncheckedRow(io.realm.internal.UncheckedRow)

Example 5 with UncheckedRow

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

the class RealmResults method createBacklinkResults.

static <T extends RealmModel> RealmResults<T> createBacklinkResults(BaseRealm realm, Row row, Class<T> srcTableType, String srcFieldName) {
    if (!(row instanceof UncheckedRow)) {
        throw new IllegalArgumentException("Row is " + row.getClass());
    }
    UncheckedRow uncheckedRow = (UncheckedRow) row;
    Table srcTable = realm.getSchema().getTable(srcTableType);
    return new RealmResults<T>(realm, Collection.createBacklinksCollection(realm.sharedRealm, uncheckedRow, srcTable, srcFieldName), srcTableType);
}
Also used : Table(io.realm.internal.Table) UncheckedRow(io.realm.internal.UncheckedRow)

Aggregations

UncheckedRow (io.realm.internal.UncheckedRow)5 Table (io.realm.internal.Table)2 RealmObjectProxy (io.realm.internal.RealmObjectProxy)1