PARENT
- Class of the parent entityELEMENT
- Class of the element entitypublic class RelationList<PARENT,ELEMENT> extends AbstractList<ELEMENT> implements Serializable
RelationLists load their content lazy. At the beginning only the size is calculated. But the element entities are not loaded when the main entity is loaded. When a get method is called on the list the requested element is loaded through the backend. If you want avoid too many server roundtrips and you know that a lot of elements will be requested you should use the subList method. The subList method of a RelationList will return a unmodifiable List with all elements of the selected range preloaded.
Normally the use of this class should be completely transparent. But you have to know the additional meaning of the subList method.
As soon as this List should be changed it is loaded completely. This could be improved but at the moment it is the easiest way to make sure that the changes as saved when the main entity is saved.
modCount
Constructor and Description |
---|
RelationList(Repository repository,
Class<ELEMENT> elementClass,
PARENT parent,
String crossName) |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
ELEMENT element) |
ELEMENT |
get(int index) |
boolean |
isLoaded() |
ELEMENT |
remove(int index) |
ELEMENT |
set(int index,
ELEMENT element) |
int |
size() |
List<ELEMENT> |
subList(int fromIndex,
int toIndex) |
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
public RelationList(Repository repository, Class<ELEMENT> elementClass, PARENT parent, String crossName)
public boolean isLoaded()
public ELEMENT get(int index)
public int size()
size
in interface Collection<ELEMENT>
size
in interface List<ELEMENT>
size
in class AbstractCollection<ELEMENT>
public void add(int index, ELEMENT element)
Copyright © 2019. All rights reserved.