return unmodifiable collections

This commit is contained in:
zzz
2011-10-17 17:28:37 +00:00
parent 46a1506c51
commit 5f7c971345

View File

@ -9,6 +9,7 @@ package net.i2p.router.networkdb.kademlia;
*/
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;
import java.util.HashSet;
@ -56,24 +57,27 @@ class TransientDataStore implements DataStore {
return _data.size();
}
/**
* @return Unmodifiable view, not a copy
*/
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
*/
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
*/
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 */