Package io.github.nejckorasa.result
Class CmpResult<B,W>
- java.lang.Object
-
- io.github.nejckorasa.result.CmpResult<B,W>
-
public class CmpResult<B,W> extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Diff,Collection<CmpPair<B,W>>>
asMap()
void
forEach(Consumer<CmpPair<B,W>> action)
Performs action on each compare pairvoid
forEachChanged(Consumer<CmpPair<B,W>> action)
Performs action on each changed compare pairvoid
forEachUnchanged(Consumer<CmpPair<B,W>> action)
Performs action on each unchanged compare pairList<CmpPair<B,W>>
getAdded()
Gets all compare pairs of items added to working collectionList<W>
getAddedItems()
Gets all items added to working collectionList<CmpPair<B,W>>
getAll()
Gets all compare pairs, changed and unchangedList<CmpPair<B,W>>
getChanged()
Gets all compare pairs of changed itemsint
getChangesCount()
Gets number of changes.List<CmpPair<B,W>>
getDifferent()
Gets all compare pairs different items - items removed from base collection or added to working collectionint
getDifferentCount()
Gets number of different items = items removed from base collection or added to working collection.List<Object>
getDifferentItems()
Gets all items removed from base collection or added to working collectionList<CmpPair<B,W>>
getRemoved()
Gets all compare pairs of items removed from base collectionList<B>
getRemovedItems()
Gets all items removed from base collectionList<CmpPair<B,W>>
getUnchanged()
Gets all compare pairs of unchanged itemsList<CmpPair<B,W>>
getUpdated()
Gets all compare pairs of items that exist in both collections but were updated.boolean
hasChanges()
boolean
hasDifferences()
Stream<CmpPair<B,W>>
stream()
Streams all compare pairsStream<CmpPair<B,W>>
streamChanged()
Streams all changed compare pairsStream<CmpPair<B,W>>
streamDifferent()
Streams all different compare pairsStream<CmpPair<B,W>>
streamUnchanged()
Streams all unchanged compare pairsString
toString()
-
-
-
Method Detail
-
getAll
public List<CmpPair<B,W>> getAll()
Gets all compare pairs, changed and unchanged- Returns:
- list of compare pairs
-
getRemoved
public List<CmpPair<B,W>> getRemoved()
Gets all compare pairs of items removed from base collection- Returns:
- list of compare pairs
-
getAdded
public List<CmpPair<B,W>> getAdded()
Gets all compare pairs of items added to working collection- Returns:
- list of compare pairs
-
getUpdated
public List<CmpPair<B,W>> getUpdated()
Gets all compare pairs of items that exist in both collections but were updated. Updated means changed based on equals function.- Returns:
- list of compare pairs
-
getUnchanged
public List<CmpPair<B,W>> getUnchanged()
Gets all compare pairs of unchanged items- Returns:
- list of compare pairs
-
getChanged
public List<CmpPair<B,W>> getChanged()
Gets all compare pairs of changed items- Returns:
- list of compare pairs
-
getDifferent
public List<CmpPair<B,W>> getDifferent()
Gets all compare pairs different items - items removed from base collection or added to working collection- Returns:
- list of compare pairs
-
getAddedItems
public List<W> getAddedItems()
Gets all items added to working collection- Returns:
- list of added items
-
getRemovedItems
public List<B> getRemovedItems()
Gets all items removed from base collection- Returns:
- list of removed items
-
getDifferentItems
public List<Object> getDifferentItems()
Gets all items removed from base collection or added to working collection- Returns:
- list different items
-
getChangesCount
public int getChangesCount()
Gets number of changes. Sum of removed, added, updated items.- Returns:
- changes count
-
hasChanges
public boolean hasChanges()
- Returns:
- true if changes exist
-
getDifferentCount
public int getDifferentCount()
Gets number of different items = items removed from base collection or added to working collection.- Returns:
- number of different items
- See Also:
getDifferent()
-
hasDifferences
public boolean hasDifferences()
- Returns:
- true if differences exist
- See Also:
getDifferent()
-
forEach
public void forEach(Consumer<CmpPair<B,W>> action)
Performs action on each compare pair- Parameters:
action
- action to perform
-
forEachChanged
public void forEachChanged(Consumer<CmpPair<B,W>> action)
Performs action on each changed compare pair- Parameters:
action
- action to perform
-
forEachUnchanged
public void forEachUnchanged(Consumer<CmpPair<B,W>> action)
Performs action on each unchanged compare pair- Parameters:
action
- action to perform
-
streamChanged
public Stream<CmpPair<B,W>> streamChanged()
Streams all changed compare pairs- Returns:
- stream
-
streamUnchanged
public Stream<CmpPair<B,W>> streamUnchanged()
Streams all unchanged compare pairs- Returns:
- stream
-
streamDifferent
public Stream<CmpPair<B,W>> streamDifferent()
Streams all different compare pairs- Returns:
- stream
- See Also:
getDifferent()
-
asMap
public Map<Diff,Collection<CmpPair<B,W>>> asMap()
- Returns:
- compare result as a map with
Diff
as keys
-
-