E
- The class of objects in this listpublic class RealmList<E extends RealmObject>
extends java.util.AbstractList<E>
RealmObject
.
RealmList has two modes: A managed and non-managed mode. In managed mode all objects are persisted
inside a Realm, in non-managed mode it functions as an ArrayList.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MANAGED_OBJECTS_NOT_ALLOWED_MESSAGE |
Constructor and Description |
---|
RealmList()
Create a RealmList in non-managed mode, where the elements are not controlled by a Realm.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E object) |
void |
add(int location,
E object) |
void |
clear() |
E |
first()
Find the first object.
|
E |
get(int location) |
E |
last()
Find the last object.
|
void |
move(int oldPos,
int newPos)
Moves an object from one position to another, while maintaining a fixed sized list.
|
E |
remove(int location) |
E |
set(int location,
E object) |
int |
size() |
java.lang.String |
toString() |
RealmQuery<E> |
where()
Returns a RealmQuery, which can be used to query for specific objects of this class
|
addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
public static final java.lang.String MANAGED_OBJECTS_NOT_ALLOWED_MESSAGE
public RealmList()
ArrayList
and it is not possible
to query the objects in this state.
Use Realm.copyToRealm(Iterable)
to properly persist it's elements in
Realm.public void add(int location, E object)
add
in interface java.util.List<E extends RealmObject>
add
in class java.util.AbstractList<E extends RealmObject>
public boolean add(E object)
add
in interface java.util.Collection<E extends RealmObject>
add
in interface java.util.List<E extends RealmObject>
add
in class java.util.AbstractList<E extends RealmObject>
public E set(int location, E object)
set
in interface java.util.List<E extends RealmObject>
set
in class java.util.AbstractList<E extends RealmObject>
public void move(int oldPos, int newPos)
oldPos
- Index of RealmObject to move.newPos
- Target position. If newPos < oldPos the object at the location will be shifted
to the right. If oldPos < newPos, indexes > oldPos will be shifted once to the
left.java.lang.IndexOutOfBoundsException
- if any position is outside [0, size()[.public void clear()
clear
in interface java.util.Collection<E extends RealmObject>
clear
in interface java.util.List<E extends RealmObject>
clear
in class java.util.AbstractList<E extends RealmObject>
public E remove(int location)
remove
in interface java.util.List<E extends RealmObject>
remove
in class java.util.AbstractList<E extends RealmObject>
public E get(int location)
get
in interface java.util.List<E extends RealmObject>
get
in class java.util.AbstractList<E extends RealmObject>
public E first()
null
if the list is empty.public E last()
null
if the list is empty.public int size()
size
in interface java.util.Collection<E extends RealmObject>
size
in interface java.util.List<E extends RealmObject>
size
in class java.util.AbstractCollection<E extends RealmObject>
public RealmQuery<E> where()
RealmQuery
public java.lang.String toString()
toString
in class java.util.AbstractCollection<E extends RealmObject>