Removing unused methods on Cache and synchronizing it since FieldAttributes contains a static instance of this type.

This commit is contained in:
Joel Leitch 2011-01-10 23:20:37 +00:00
parent 1e2fbd81f5
commit 439d931c5a
2 changed files with 3 additions and 23 deletions

View File

@ -48,14 +48,4 @@ interface Cache<K, V> {
* @return the value for the given {@code key}
*/
V removeElement(K key);
/**
* Removes everything from this cache.
*/
void clear();
/**
* @return the number of objects in this cache
*/
int size();
}

View File

@ -37,28 +37,18 @@ final class LruCache<K, V> extends LinkedHashMap<K, V> implements Cache<K, V> {
this.maxCapacity = maxCapacity;
}
public void addElement(K key, V value) {
public synchronized void addElement(K key, V value) {
put(key, value);
}
@Override
public void clear() {
super.clear();
}
public V getElement(K key) {
public synchronized V getElement(K key) {
return get(key);
}
public V removeElement(K key) {
public synchronized V removeElement(K key) {
return remove(key);
}
@Override
public int size() {
return super.size();
}
@Override
protected boolean removeEldestEntry(Map.Entry<K, V> entry) {
return size() > maxCapacity;