I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 5f7c9713 authored by zzz's avatar zzz
Browse files

return unmodifiable collections

parent 46a1506c
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ package net.i2p.router.networkdb.kademlia; ...@@ -9,6 +9,7 @@ package net.i2p.router.networkdb.kademlia;
*/ */
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.HashSet; import java.util.HashSet;
...@@ -56,24 +57,27 @@ class TransientDataStore implements DataStore { ...@@ -56,24 +57,27 @@ class TransientDataStore implements DataStore {
return _data.size(); return _data.size();
} }
/**
* @return Unmodifiable view, not a copy
*/
public Set<Hash> getKeys() { public Set<Hash> getKeys() {
return new HashSet(_data.keySet()); return Collections.unmodifiableSet(_data.keySet());
} }
/** /**
* @return not a copy * @return Unmodifiable view, not a copy
* @since 0.8.3 * @since 0.8.3
*/ */
public Collection<DatabaseEntry> getEntries() { public Collection<DatabaseEntry> getEntries() {
return _data.values(); return Collections.unmodifiableCollection(_data.values());
} }
/** /**
* @return not a copy * @return Unmodifiable view, not a copy
* @since 0.8.3 * @since 0.8.3
*/ */
public Set<Map.Entry<Hash, DatabaseEntry>> getMapEntries() { public Set<Map.Entry<Hash, DatabaseEntry>> getMapEntries() {
return _data.entrySet(); return Collections.unmodifiableSet(_data.entrySet());
} }
/** for PersistentDataStore only - don't use here @throws IAE always */ /** for PersistentDataStore only - don't use here @throws IAE always */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment