T
- the type of objects stored in this listpublic abstract class SafeList<T> extends Object implements Iterable<T>
Constructor and Description |
---|
SafeList() |
Modifier and Type | Method and Description |
---|---|
SafeList<T> |
add(T item)
Adds a new item to the list.
|
SafeList<T> |
addAll(Collection<T> items)
Adds all items to the list.
|
SafeList<T> |
clear()
Clears the list.
|
boolean |
contains(T item)
Determines if the list contains the given item.
|
List<T> |
copyList()
Creates a copy of the underlying list.
|
protected abstract T |
copyValue(T value)
Creates a copy of the given value.
|
List<T> |
data()
Provides readonly access to the underlying list.
|
boolean |
equals(Object obj) |
void |
forEach(Consumer<? super T> action) |
int |
hashCode() |
boolean |
isEmpty()
Determines if the list is empty.
|
boolean |
isFilled()
Determines if the list is not empty.
|
Iterator<T> |
iterator() |
List<T> |
modify()
Provides read and write access to the underlying list.
|
List<T> |
original()
Provides access to the list which was origrinally used to supply contents.
|
void |
setData(List<T> newData)
Sets the underyling list to use.
|
int |
size()
Determines the size of the list.
|
Spliterator<T> |
spliterator() |
String |
toString() |
protected abstract boolean |
valueNeedsCopy()
Determines if values in this list must be copied if the list is copied.
|
public List<T> data()
public List<T> modify()
protected abstract boolean valueNeedsCopy()
protected abstract T copyValue(T value)
value
- the value to copypublic List<T> original()
In contrast to modify()
this will not create a new list if none is present yet.
Therefore the result might be readonly. The is mainly used by the storage engine to
re-use internal data structures as much as possible.
public void setData(List<T> newData)
As original()
this should only be used by the storage engine to insert a database specific
implementation which can later be re-used.
newData
- the new list to usepublic SafeList<T> add(T item)
item
- the item to addpublic SafeList<T> addAll(Collection<T> items)
items
- the items to addpublic int size()
public boolean isEmpty()
public boolean isFilled()
public boolean contains(T item)
item
- the item to check forpublic Spliterator<T> spliterator()
spliterator
in interface Iterable<T>
public List<T> copyList()
This is used by the framework to permit change tracking. If we wouldn't create a copy of the list, the "original" backup and the list in the entity would be the same and therefore no modifications would be recognized.
Copyright © 2018. All rights reserved.