|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fuin.utils4j.ChangeTrackingUniqueList
public class ChangeTrackingUniqueList
A wrapper for lists that keeps track of all changes made to the list since
construction. Only adding, replacing or deleting elements is tracked (not
changes inside the objects). Duplicates elements are not allowed for the list
- This is like a Set but at the same time ordered like a List
. It's also possible to revert all changes.
| Constructor Summary | |
|---|---|
ChangeTrackingUniqueList(List list)
Constructor with covered list. |
|
| Method Summary | |
|---|---|
void |
add(int index,
Object o)
|
boolean |
add(Object o)
|
boolean |
addAll(Collection c)
|
boolean |
addAll(int index,
Collection c)
|
void |
clear()
|
boolean |
contains(Object o)
|
boolean |
containsAll(Collection c)
|
Object |
get(int index)
|
List |
getAdded()
Returns added elements. |
List |
getDeleted()
Returns deleted elements. |
boolean |
hasChangedSinceTagging()
Returns if the content of the object has changed since setting the tag. |
int |
indexOf(Object o)
|
boolean |
isChanged()
Returns if the list has changed. |
boolean |
isEmpty()
|
boolean |
isTagged()
Returns if the object is currently tagged. |
Iterator |
iterator()
|
int |
lastIndexOf(Object o)
|
ListIterator |
listIterator()
|
ListIterator |
listIterator(int index)
|
Object |
remove(int index)
|
boolean |
remove(Object o)
|
boolean |
removeAll(Collection c)
|
boolean |
retainAll(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. |
Object |
set(int index,
Object o)
|
int |
size()
|
List |
subList(int fromIndex,
int toIndex)
|
void |
tag()
Start memorizing changes. |
Object[] |
toArray()
|
Object[] |
toArray(Object[] a)
|
String |
toString()
|
void |
untag()
Stop memorizing changes and clear internal state. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public ChangeTrackingUniqueList(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.| Method Detail |
|---|
public final boolean isChanged()
isTagged() returns true) this method will
always return false.
true else
false.public final List getDeleted()
isTagged() returns true) this method will always
return an empty list.
public final 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(Object o)
add in interface Collectionadd in interface List
public final void add(int index,
Object o)
add in interface Listpublic final boolean addAll(Collection c)
addAll in interface CollectionaddAll in interface List
public final boolean addAll(int index,
Collection c)
addAll in interface Listpublic final void clear()
clear in interface Collectionclear in interface Listpublic final boolean contains(Object o)
contains in interface Collectioncontains in interface Listpublic final boolean containsAll(Collection c)
containsAll in interface CollectioncontainsAll in interface Listpublic final Object get(int index)
get in interface Listpublic final int indexOf(Object o)
indexOf in interface Listpublic final boolean isEmpty()
isEmpty in interface CollectionisEmpty in interface Listpublic final Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface Listpublic final int lastIndexOf(Object o)
lastIndexOf in interface Listpublic final ListIterator listIterator()
listIterator in interface Listpublic final ListIterator listIterator(int index)
listIterator in interface Listpublic final boolean remove(Object o)
remove in interface Collectionremove in interface Listpublic final Object remove(int index)
remove in interface Listpublic final boolean removeAll(Collection c)
removeAll in interface CollectionremoveAll in interface Listpublic final boolean retainAll(Collection c)
retainAll in interface CollectionretainAll in interface List
public final Object set(int index,
Object o)
set in interface Listpublic final int size()
size in interface Collectionsize in interface List
public final List subList(int fromIndex,
int toIndex)
subList in interface Listpublic final Object[] toArray()
toArray in interface CollectiontoArray in interface Listpublic final Object[] toArray(Object[] a)
toArray in interface CollectiontoArray in interface Listpublic final String toString()
toString in class Objectpublic final boolean hasChangedSinceTagging()
hasChangedSinceTagging in interface Taggabletrue else
false.public final boolean isTagged()
isTagged in interface Taggabletrue else false.public final void revertToTag()
revertToTag in interface Taggablepublic final void tag()
tag in interface Taggablepublic final void untag()
untag in interface Taggable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||