source: josm/trunk/src/org/openstreetmap/josm/data/osm/DefaultChangesetCacheEvent.java@ 13033

Last change on this file since 13033 was 12189, checked in by michael2402, 7 years ago

See #14794: Javadoc for data.osm package

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.util.Collection;
5import java.util.Collections;
6import java.util.HashSet;
7import java.util.Set;
8
9/**
10 * The default event implementation that is used to indicate a change in the {@link ChangesetCache}
11 */
12public class DefaultChangesetCacheEvent implements ChangesetCacheEvent {
13
14 private final Set<Changeset> added;
15 private final Set<Changeset> modified;
16 private final Set<Changeset> removed;
17 private final ChangesetCache source;
18
19 /**
20 * Creates a basic, empty {@link ChangesetCacheEvent}
21 * @param source The source changeset
22 */
23 public DefaultChangesetCacheEvent(ChangesetCache source) {
24 this.source = source;
25 added = new HashSet<>();
26 modified = new HashSet<>();
27 removed = new HashSet<>();
28 }
29
30 @Override
31 public ChangesetCache getSource() {
32 return source;
33 }
34
35 @Override
36 public Collection<Changeset> getAddedChangesets() {
37 return Collections.unmodifiableCollection(added);
38 }
39
40 @Override
41 public Collection<Changeset> getRemovedChangesets() {
42 return Collections.unmodifiableCollection(removed);
43 }
44
45 @Override
46 public Collection<Changeset> getUpdatedChangesets() {
47 return Collections.unmodifiableCollection(modified);
48 }
49
50 /**
51 * Adds a {@link Changeset} to the added list
52 * @param cs the {@link Changeset}
53 */
54 public void rememberAddedChangeset(Changeset cs) {
55 if (cs == null) return;
56 added.add(cs);
57 }
58
59 /**
60 * Adds a {@link Changeset} to the updated list
61 * @param cs the {@link Changeset}
62 */
63 public void rememberUpdatedChangeset(Changeset cs) {
64 if (cs == null) return;
65 modified.add(cs);
66 }
67
68 /**
69 * Adds a {@link Changeset} to the removed list
70 * @param cs the {@link Changeset}
71 */
72 public void rememberRemovedChangeset(Changeset cs) {
73 if (cs == null) return;
74 removed.add(cs);
75 }
76
77 /**
78 * Checks if this event contains any {@link Changeset}s
79 * @return <code>true</code> if changesets were added
80 */
81 public boolean isEmpty() {
82 return added.isEmpty() && modified.isEmpty() && removed.isEmpty();
83 }
84}
Note: See TracBrowser for help on using the repository browser.