Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
* Removed deprecated API `RealmObject.removeChangeListeners()`. Use `RealmObject.removeAllChangeListeners()` instead.
* `SyncUser.Callback` to becomes generic.
* Removed `SyncUser.getAccessToken` method from public API, and rename it to `getRefreshToken`.
* Relaxed upper bound of type parameter of `RealmList`, `RealmQuery`, `RealmResults`, `RealmCollection`, `OrderedRealmCollection` and `OrderedRealmCollectionSnapshot`.

## Deprecated

## Enhancements

* Now users can use `String`, `byte[]`, `Boolean`, `Long`, `Integer`, `Short`, `Byte`, `Double`, `Float` and `Date` as a type parameter of `RealmList`.

## Bug Fixes

## Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1552,4 +1552,11 @@ public void onChange(RealmList<Object> collection, @Nullable OrderedCollectionCh
realm.commitTransaction();
assertEquals(1, listenerCalledCount.get());
}

@Test
public void createSnapshot() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage(is(RealmList.ALLOWED_ONLY_FOR_REALM_MODEL_ELEMENT_MESSAGE));
list.createSnapshot();
}
}
5 changes: 4 additions & 1 deletion realm/realm-library/src/main/java/io/realm/RealmList.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
public class RealmList<E> extends AbstractList<E> implements OrderedRealmCollection<E> {

private static final String ONLY_IN_MANAGED_MODE_MESSAGE = "This method is only available in managed mode.";
private static final String ALLOWED_ONLY_FOR_REALM_MODEL_ELEMENT_MESSAGE = "This feature is available only when the element type is implementing RealmModel.";
static final String ALLOWED_ONLY_FOR_REALM_MODEL_ELEMENT_MESSAGE = "This feature is available only when the element type is implementing RealmModel.";
public static final String REMOVE_OUTSIDE_TRANSACTION_ERROR = "Objects can only be removed from inside a write transaction.";

@Nullable
Expand Down Expand Up @@ -754,6 +754,9 @@ public OrderedRealmCollectionSnapshot<E> createSnapshot() {
throw new UnsupportedOperationException(ONLY_IN_MANAGED_MODE_MESSAGE);
}
checkValidRealm();
if (!osListOperator.forRealmModel()) {
throw new IllegalStateException(ALLOWED_ONLY_FOR_REALM_MODEL_ELEMENT_MESSAGE);
}
if (className != null) {
return new OrderedRealmCollectionSnapshot<>(
realm,
Expand Down