use of io.realm.internal.SortDescriptor 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.SortDescriptor in project realm-java by realm.
the class OrderedRealmCollectionImpl method sort.
/**
* {@inheritDoc}
*/
@Override
public RealmResults<E> sort(String fieldName, Sort sortOrder) {
SortDescriptor sortDescriptor = SortDescriptor.getInstanceForSort(collection.getTable(), fieldName, sortOrder);
Collection sortedCollection = collection.sort(sortDescriptor);
return createLoadedResults(sortedCollection);
}
use of io.realm.internal.SortDescriptor in project realm-java by realm.
the class RealmQuery method findAllSorted.
/**
* Finds all objects that fulfill the query conditions and sorted by specific field name.
* <p>
* Sorting is currently limited to character sets in 'Latin Basic', 'Latin Supplement', 'Latin Extended A',
* 'Latin Extended B' (UTF-8 range 0-591). For other character sets, sorting will have no effect.
*
* @param fieldName the field name to sort by.
* @param sortOrder how to sort the results.
* @return a {@link io.realm.RealmResults} containing objects. If no objects match the condition, a list with zero
* objects is returned.
* @throws java.lang.IllegalArgumentException if field name does not exist or it belongs to a child
* {@link RealmObject} or a child {@link RealmList}.
*/
@SuppressWarnings("unchecked")
public RealmResults<E> findAllSorted(String fieldName, Sort sortOrder) {
realm.checkIfValid();
SortDescriptor sortDescriptor = SortDescriptor.getInstanceForSort(query.getTable(), fieldName, sortOrder);
return createRealmResults(query, sortDescriptor, null, true);
}
use of io.realm.internal.SortDescriptor in project realm-java by realm.
the class RealmQuery method findAllSortedAsync.
/**
* Similar to {@link #findAllSorted(String, Sort)} but runs asynchronously on a worker thread
* (need a Realm opened from a looper thread to work).
*
* @return immediately an empty {@link RealmResults}. Users need to register a listener
* {@link io.realm.RealmResults#addChangeListener(RealmChangeListener)} to be notified when the query completes.
* @throws java.lang.IllegalArgumentException if field name does not exist or it belongs to a child
* {@link RealmObject} or a child {@link RealmList}.
*/
public RealmResults<E> findAllSortedAsync(final String fieldName, final Sort sortOrder) {
realm.checkIfValid();
realm.sharedRealm.capabilities.checkCanDeliverNotification(ASYNC_QUERY_WRONG_THREAD_MESSAGE);
SortDescriptor sortDescriptor = SortDescriptor.getInstanceForSort(query.getTable(), fieldName, sortOrder);
return createRealmResults(query, sortDescriptor, null, false);
}
use of io.realm.internal.SortDescriptor in project realm-java by realm.
the class RealmQuery method distinct.
/**
* Returns a distinct set of objects of a specific class. If the result is sorted, the first
* object will be returned in case of multiple occurrences, otherwise it is undefined which
* object is returned.
*
* @param fieldName the field name.
* @return a non-null {@link RealmResults} containing the distinct objects.
* @throws IllegalArgumentException if a field is {@code null}, does not exist, is an unsupported type,
* is not indexed, or points to linked fields.
*/
public RealmResults<E> distinct(String fieldName) {
realm.checkIfValid();
SortDescriptor distinctDescriptor = SortDescriptor.getInstanceForDistinct(query.getTable(), fieldName);
return createRealmResults(query, null, distinctDescriptor, true);
}
Aggregations