public class ChangeTrackingUniqueList extends java.lang.Object implements java.util.List, Taggable
Set
but at the same time ordered like a List
. It's also possible to revert all changes.Constructor and Description |
---|
ChangeTrackingUniqueList(java.util.List list)
Constructor with covered list.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
java.lang.Object o) |
boolean |
add(java.lang.Object o) |
boolean |
addAll(java.util.Collection c) |
boolean |
addAll(int index,
java.util.Collection c) |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection c) |
java.lang.Object |
get(int index) |
java.util.List |
getAdded()
Returns added elements.
|
java.util.List |
getDeleted()
Returns deleted elements.
|
boolean |
hasChangedSinceTagging()
Returns if the content of the object has changed since setting the tag.
|
int |
indexOf(java.lang.Object o) |
boolean |
isChanged()
Returns if the list has changed.
|
boolean |
isEmpty() |
boolean |
isTagged()
Returns if the object is currently tagged.
|
java.util.Iterator |
iterator() |
int |
lastIndexOf(java.lang.Object o) |
java.util.ListIterator |
listIterator() |
java.util.ListIterator |
listIterator(int index) |
java.lang.Object |
remove(int index) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection c) |
boolean |
retainAll(java.util.Collection c) |
void |
revert()
Roll back all changes made since construction.
|
void |
revertToTag()
Reverts all changes made since setting the tag and clears internal state.
|
java.lang.Object |
set(int index,
java.lang.Object o) |
int |
size() |
java.util.List |
subList(int fromIndex,
int toIndex) |
void |
tag()
Start memorizing changes.
|
java.lang.Object[] |
toArray() |
java.lang.Object[] |
toArray(java.lang.Object[] a) |
java.lang.String |
toString() |
void |
untag()
Stop memorizing changes and clear internal state.
|
public ChangeTrackingUniqueList(java.util.List list)
isTagged()
will return true
without
calling tag()
first. If this behavior is not wanted you can call
untag()
after constructing the list.list
- Wrapped list - Be aware that this list will be changed by this
class. There is no internal copy of the list - The reference
itself is used.public final boolean isChanged()
isTagged()
returns true
) this method will
always return false
.true
else
false
.public final java.util.List getDeleted()
isTagged()
returns true
) this method will always
return an empty list.public final java.util.List getAdded()
isTagged()
returns true
) this method will always
return an empty list.public final void revert()
revertToTag()
. If the list is not in tag mode (
this means isTagged()
returns true
) this method
will do nothing.public final boolean add(java.lang.Object o)
add
in interface java.util.Collection
add
in interface java.util.List
public final void add(int index, java.lang.Object o)
add
in interface java.util.List
public final boolean addAll(java.util.Collection c)
addAll
in interface java.util.Collection
addAll
in interface java.util.List
public final boolean addAll(int index, java.util.Collection c)
addAll
in interface java.util.List
public final void clear()
clear
in interface java.util.Collection
clear
in interface java.util.List
public final boolean contains(java.lang.Object o)
contains
in interface java.util.Collection
contains
in interface java.util.List
public final boolean containsAll(java.util.Collection c)
containsAll
in interface java.util.Collection
containsAll
in interface java.util.List
public final java.lang.Object get(int index)
get
in interface java.util.List
public final int indexOf(java.lang.Object o)
indexOf
in interface java.util.List
public final boolean isEmpty()
isEmpty
in interface java.util.Collection
isEmpty
in interface java.util.List
public final java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
iterator
in interface java.util.List
public final int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List
public final java.util.ListIterator listIterator()
listIterator
in interface java.util.List
public final java.util.ListIterator listIterator(int index)
listIterator
in interface java.util.List
public final boolean remove(java.lang.Object o)
remove
in interface java.util.Collection
remove
in interface java.util.List
public final java.lang.Object remove(int index)
remove
in interface java.util.List
public final boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Collection
removeAll
in interface java.util.List
public final boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection
retainAll
in interface java.util.List
public final java.lang.Object set(int index, java.lang.Object o)
set
in interface java.util.List
public final int size()
size
in interface java.util.Collection
size
in interface java.util.List
public final java.util.List subList(int fromIndex, int toIndex)
subList
in interface java.util.List
public final java.lang.Object[] toArray()
toArray
in interface java.util.Collection
toArray
in interface java.util.List
public final java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Collection
toArray
in interface java.util.List
public final java.lang.String toString()
toString
in class java.lang.Object
public final boolean hasChangedSinceTagging()
hasChangedSinceTagging
in interface Taggable
true
else
false
.public final boolean isTagged()
public final void revertToTag()
revertToTag
in interface Taggable