[2711] | 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 |
|
---|
[9059] | 9 | public class DefaultChangesetCacheEvent implements ChangesetCacheEvent {
|
---|
[2711] | 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;
|
---|
[7005] | 18 | added = new HashSet<>();
|
---|
| 19 | modified = new HashSet<>();
|
---|
| 20 | removed = new HashSet<>();
|
---|
[2711] | 21 | }
|
---|
| 22 |
|
---|
[6084] | 23 | @Override
|
---|
[2711] | 24 | public Collection<Changeset> getAddedChangesets() {
|
---|
| 25 | return Collections.unmodifiableCollection(added);
|
---|
| 26 | }
|
---|
[8510] | 27 |
|
---|
[6084] | 28 | @Override
|
---|
[2711] | 29 | public Collection<Changeset> getRemovedChangesets() {
|
---|
| 30 | return Collections.unmodifiableCollection(removed);
|
---|
| 31 | }
|
---|
[8510] | 32 |
|
---|
[6084] | 33 | @Override
|
---|
[2711] | 34 | public ChangesetCache getSource() {
|
---|
| 35 | return source;
|
---|
| 36 | }
|
---|
[8510] | 37 |
|
---|
[6084] | 38 | @Override
|
---|
[2711] | 39 | public Collection<Changeset> getUpdatedChangesets() {
|
---|
| 40 | return Collections.unmodifiableCollection(modified);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | public void rememberAddedChangeset(Changeset cs) {
|
---|
| 44 | if (cs == null) return;
|
---|
| 45 | added.add(cs);
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | public void rememberUpdatedChangeset(Changeset cs) {
|
---|
| 49 | if (cs == null) return;
|
---|
| 50 | modified.add(cs);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | public void rememberRemovedChangeset(Changeset cs) {
|
---|
| 54 | if (cs == null) return;
|
---|
| 55 | removed.add(cs);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | public boolean isEmpty() {
|
---|
| 59 | return added.isEmpty() && modified.isEmpty() && removed.isEmpty();
|
---|
| 60 | }
|
---|
| 61 | }
|
---|