| 1 | // License: GPL. For details, see LICENSE file. |
|---|
| 2 | package org.openstreetmap.josm.data.osm; |
|---|
| 3 | |
|---|
| 4 | import java.util.Collection; |
|---|
| 5 | import java.util.Collections; |
|---|
| 6 | import java.util.HashSet; |
|---|
| 7 | import java.util.Set; |
|---|
| 8 | |
|---|
| 9 | public class DefaultChangesetCacheEvent implements ChangesetCacheEvent{ |
|---|
| 10 | |
|---|
| 11 | private final Set<Changeset> added; |
|---|
| 12 | private final Set<Changeset> modified; |
|---|
| 13 | private final Set<Changeset> removed; |
|---|
| 14 | private final ChangesetCache source; |
|---|
| 15 | |
|---|
| 16 | public DefaultChangesetCacheEvent(ChangesetCache source) { |
|---|
| 17 | this.source = source; |
|---|
| 18 | added = new HashSet<Changeset>(); |
|---|
| 19 | modified = new HashSet<Changeset>(); |
|---|
| 20 | removed = new HashSet<Changeset>(); |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | public Collection<Changeset> getAddedChangesets() { |
|---|
| 24 | return Collections.unmodifiableCollection(added); |
|---|
| 25 | } |
|---|
| 26 | public Collection<Changeset> getRemovedChangesets() { |
|---|
| 27 | return Collections.unmodifiableCollection(removed); |
|---|
| 28 | } |
|---|
| 29 | public ChangesetCache getSource() { |
|---|
| 30 | return source; |
|---|
| 31 | } |
|---|
| 32 | public Collection<Changeset> getUpdatedChangesets() { |
|---|
| 33 | return Collections.unmodifiableCollection(modified); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | public void rememberAddedChangeset(Changeset cs) { |
|---|
| 37 | if (cs == null) return; |
|---|
| 38 | added.add(cs); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | public void rememberUpdatedChangeset(Changeset cs) { |
|---|
| 42 | if (cs == null) return; |
|---|
| 43 | modified.add(cs); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | public void rememberRemovedChangeset(Changeset cs) { |
|---|
| 47 | if (cs == null) return; |
|---|
| 48 | removed.add(cs); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | public boolean isEmpty() { |
|---|
| 52 | return added.isEmpty() && modified.isEmpty() && removed.isEmpty(); |
|---|
| 53 | } |
|---|
| 54 | } |
|---|