use of io.realm.internal.Collection in project realm-java by realm.
the class RealmQuery method createRealmResults.
private RealmResults<E> createRealmResults(TableQuery query, SortDescriptor sortDescriptor, SortDescriptor distinctDescriptor, boolean loadResults) {
RealmResults<E> results;
Collection collection = new Collection(realm.sharedRealm, query, sortDescriptor, distinctDescriptor);
if (isDynamicQuery()) {
results = new RealmResults<E>(realm, collection, className);
} else {
results = new RealmResults<E>(realm, collection, clazz);
}
if (loadResults) {
results.load();
}
return results;
}
use of io.realm.internal.Collection in project realm-java by realm.
the class RealmResults method distinct.
/**
* @deprecated use {@link RealmQuery#distinct(String)} on the return value of {@link #where()} instead. This will
* be removed in coming 3.x.x minor releases.
*/
@Deprecated
public RealmResults<E> distinct(String fieldName) {
SortDescriptor distinctDescriptor = SortDescriptor.getInstanceForDistinct(collection.getTable(), fieldName);
Collection distinctCollection = collection.distinct(distinctDescriptor);
return createLoadedResults(distinctCollection);
}
use of io.realm.internal.Collection in project realm-java by realm.
the class OrderedRealmCollectionImpl method sort.
/**
* {@inheritDoc}
*/
@Override
public RealmResults<E> sort(String[] fieldNames, Sort[] sortOrders) {
SortDescriptor sortDescriptor = SortDescriptor.getInstanceForSort(collection.getTable(), fieldNames, sortOrders);
Collection sortedCollection = collection.sort(sortDescriptor);
return createLoadedResults(sortedCollection);
}
use of io.realm.internal.Collection in project realm-java by realm.
the class OrderedRealmCollectionImpl method sort.
/**
* {@inheritDoc}
*/
@Override
public RealmResults<E> sort(String fieldName) {
SortDescriptor sortDescriptor = SortDescriptor.getInstanceForSort(collection.getTable(), fieldName, Sort.ASCENDING);
Collection sortedCollection = collection.sort(sortDescriptor);
return createLoadedResults(sortedCollection);
}
use of io.realm.internal.Collection in project realm-java by realm.
the class RealmResultsTests method size_returns_Integer_MAX_VALUE_for_huge_results.
@Test
public void size_returns_Integer_MAX_VALUE_for_huge_results() {
final Collection collection = Mockito.mock(Collection.class);
final RealmResults<AllTypes> targetResult = TestHelper.newRealmResults(realm, collection, AllTypes.class);
Mockito.when(collection.isLoaded()).thenReturn(true);
Mockito.when(collection.size()).thenReturn(((long) Integer.MAX_VALUE) - 1);
assertEquals(Integer.MAX_VALUE - 1, targetResult.size());
Mockito.when(collection.size()).thenReturn(((long) Integer.MAX_VALUE));
assertEquals(Integer.MAX_VALUE, targetResult.size());
Mockito.when(collection.size()).thenReturn(((long) Integer.MAX_VALUE) + 1);
assertEquals(Integer.MAX_VALUE, targetResult.size());
}
Aggregations