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

Skip to content
Snippets Groups Projects
Commit 9fc34895 authored by jrandom's avatar jrandom Committed by zzz
Browse files

more careful ops

parent 08be4c7b
No related branches found
No related tags found
No related merge requests found
...@@ -16,15 +16,28 @@ public class PetNameDB { ...@@ -16,15 +16,28 @@ public class PetNameDB {
_names = Collections.synchronizedMap(new HashMap()); _names = Collections.synchronizedMap(new HashMap());
} }
public PetName getByName(String name) { return (PetName)_names.get(name.toLowerCase()); } public PetName getByName(String name) {
public void add(PetName pn) { _names.put(pn.getName().toLowerCase(), pn); } if ( (name == null) || (name.length() <= 0) ) return null;
return (PetName)_names.get(name.toLowerCase());
}
public void add(PetName pn) {
if ( (pn == null) || (pn.getName() == null) ) return;
_names.put(pn.getName().toLowerCase(), pn);
}
public void clear() { _names.clear(); } public void clear() { _names.clear(); }
public boolean contains(PetName pn) { return _names.containsValue(pn); } public boolean contains(PetName pn) { return _names.containsValue(pn); }
public boolean containsName(String name) { return _names.containsKey(name.toLowerCase()); } public boolean containsName(String name) {
if ( (name == null) || (name.length() <= 0) ) return false;
return _names.containsKey(name.toLowerCase());
}
public boolean isEmpty() { return _names.isEmpty(); } public boolean isEmpty() { return _names.isEmpty(); }
public Iterator iterator() { return new LinkedList(_names.values()).iterator(); } public Iterator iterator() { return new ArrayList(_names.values()).iterator(); }
public void remove(PetName pn) { _names.values().remove(pn); } public void remove(PetName pn) {
public void removeName(String name) { _names.remove(name.toLowerCase()); } if (pn != null) _names.remove(pn.getName());
}
public void removeName(String name) {
if (name != null) _names.remove(name.toLowerCase());
}
public int size() { return _names.size(); } public int size() { return _names.size(); }
public Set getNames() { return new HashSet(_names.keySet()); } public Set getNames() { return new HashSet(_names.keySet()); }
public List getGroups() { public List getGroups() {
......
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