| 20 | import java.util.Collection; |
| 21 | |
| 22 | class CollectionChanges<T> implements Changes<T> |
| 23 | { |
| 24 | private final Collection<T> positive; |
| 25 | private final Collection<T> negative; |
| 26 | private final boolean clear; |
| 27 | |
| 28 | CollectionChanges(Collection<T> added, Collection<T> removed, boolean globallyCleared) |
| 29 | { |
| 30 | positive = added; |
| 31 | negative = removed; |
| 32 | clear = globallyCleared; |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public boolean includesGlobalClear() |
| 37 | { |
| 38 | return clear; |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public boolean isEmpty() |
| 43 | { |
| 44 | return !clear && !hasAddedItems() && !hasRemovedItems(); |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public Collection<T> getAdded() |
| 49 | { |
| 50 | return positive; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public boolean hasAddedItems() |
| 55 | { |
| 56 | return positive != null && !positive.isEmpty(); |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public Collection<T> getRemoved() |
| 61 | { |
| 62 | return negative; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public boolean hasRemovedItems() |
| 67 | { |
| 68 | return negative != null && !negative.isEmpty(); |
| 69 | } |
| 70 | } |
nothing calls this directly
no outgoing calls
no test coverage detected