The Class PatternChanges is responsible for tracking changes to a map so that the changes can be committed or rolled back at a later stage. Items can be added to the map, removed from the map or the map can be cleared.
| 26 | * cleared. |
| 27 | */ |
| 28 | public class PatternChanges<T> |
| 29 | { |
| 30 | private final Collection<T> positive; |
| 31 | private final Collection<String> negative; |
| 32 | private final boolean clear; |
| 33 | |
| 34 | public PatternChanges(Collection<T> added, Collection<String> removed, boolean globallyCleared) |
| 35 | { |
| 36 | positive = added; |
| 37 | negative = removed; |
| 38 | clear = globallyCleared; |
| 39 | } |
| 40 | |
| 41 | public boolean includesGlobalClear() |
| 42 | { |
| 43 | return clear; |
| 44 | } |
| 45 | |
| 46 | public boolean isEmpty() |
| 47 | { |
| 48 | return !clear && !hasAddedItems() && !hasRemovedItems(); |
| 49 | } |
| 50 | |
| 51 | public Collection<T> getAdded() |
| 52 | { |
| 53 | return positive; |
| 54 | } |
| 55 | |
| 56 | public boolean hasAddedItems() |
| 57 | { |
| 58 | return positive != null && !positive.isEmpty(); |
| 59 | } |
| 60 | |
| 61 | public Collection<String> getRemoved() |
| 62 | { |
| 63 | return negative; |
| 64 | } |
| 65 | |
| 66 | public boolean hasRemovedItems() |
| 67 | { |
| 68 | return negative != null && !negative.isEmpty(); |
| 69 | } |
| 70 | } |
nothing calls this directly
no outgoing calls
no test coverage detected