Package com.irurueta.hermes
Class AbstractSequentialListItemChangeDetector<T>
java.lang.Object
com.irurueta.hermes.AbstractSequentialListItemChangeDetector<T>
- Type Parameters:
T
- type of items.
- Direct Known Subclasses:
ComparableSequentialListItemChangeDetector
,SequentialListItemChangeDetector
Abstract class to detect changes between two lists of items.
Notice that returned changes in this class indicate the positions of the items when each change is applied
sequentially to the old list.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate List<UpdatedListItemChange<T>>
buildChanges
(List<T> newItemsCopy, List<T> oldItemsCopy) Finds changed items and build a list of detected update changes.private List<InsertedListItemChange<T>>
buildInserts
(List<T> newItemsCopy, List<T> oldItemsCopy) Finds inserted items and build a list of detected insert changes.private List<MovedListItemChange<T>>
buildMoves
(List<T> newItemsCopy, List<T> oldItemsCopy) Finds moved items and build a list of detected move changes.private List<RemovedListItemChange<T>>
buildRemoves
(List<T> newItemsCopy, List<T> oldItemsCopy) Finds removed items and build a list of detected remove changes.detectChanges
(List<T> newItems, List<T> oldItems) Detects changes between two lists of items.protected abstract boolean
hasContentChanged
(T newItem, T oldItem) Determines whether the content of an item has changed.protected abstract int
Determines the index of an item in a list.protected abstract boolean
notContains
(List<T> items, T item) Determines whether an item is not contained in a list.
-
Constructor Details
-
AbstractSequentialListItemChangeDetector
public AbstractSequentialListItemChangeDetector()
-
-
Method Details
-
detectChanges
Detects changes between two lists of items.- Parameters:
newItems
- new items.oldItems
- old items.- Returns:
- a list of found changes.
- Throws:
IllegalArgumentException
- if any of the provided lists is null.
-
hasContentChanged
Determines whether the content of an item has changed.- Parameters:
newItem
- new item.oldItem
- old item.- Returns:
- true if the content of the item has changed, false otherwise.
-
notContains
Determines whether an item is not contained in a list.- Parameters:
items
- list of items.item
- item to be checked.- Returns:
- true if the item is not contained in the list, false otherwise.
-
indexOf
Determines the index of an item in a list.- Parameters:
items
- list of items.item
- item to be checked.- Returns:
- index of the item in the list, or -1 if the item is not contained in the list.
-
buildRemoves
Finds removed items and build a list of detected remove changes. Notice that this method modifies the old items copy to avoid checking removed items again.- Parameters:
newItemsCopy
- new items copy.oldItemsCopy
- old items copy.- Returns:
- a list of detected remove changes.
-
buildInserts
Finds inserted items and build a list of detected insert changes. Notice that this method modifies the old items copy to avoid checking inserted items again.- Parameters:
newItemsCopy
- new items copy.oldItemsCopy
- old items copy.- Returns:
- a list of detected insert changes.
-
buildMoves
Finds moved items and build a list of detected move changes. Notice that this method modifies the old items copy to avoid checking moved items again.- Parameters:
newItemsCopy
- new items copy.oldItemsCopy
- old items copy.- Returns:
- a list of detected move changes.
-
buildChanges
Finds changed items and build a list of detected update changes.- Parameters:
newItemsCopy
- new items copy.oldItemsCopy
- old items copy.- Returns:
- a list of detected update changes.
-