Removing unused methods on Cache and synchronizing it since FieldAttributes contains a static instance of this type.
This commit is contained in:
parent
1e2fbd81f5
commit
439d931c5a
|
@ -48,14 +48,4 @@ interface Cache<K, V> {
|
||||||
* @return the value for the given {@code key}
|
* @return the value for the given {@code key}
|
||||||
*/
|
*/
|
||||||
V removeElement(K key);
|
V removeElement(K key);
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes everything from this cache.
|
|
||||||
*/
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the number of objects in this cache
|
|
||||||
*/
|
|
||||||
int size();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,28 +37,18 @@ final class LruCache<K, V> extends LinkedHashMap<K, V> implements Cache<K, V> {
|
||||||
this.maxCapacity = maxCapacity;
|
this.maxCapacity = maxCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addElement(K key, V value) {
|
public synchronized void addElement(K key, V value) {
|
||||||
put(key, value);
|
put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public synchronized V getElement(K key) {
|
||||||
public void clear() {
|
|
||||||
super.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public V getElement(K key) {
|
|
||||||
return get(key);
|
return get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public V removeElement(K key) {
|
public synchronized V removeElement(K key) {
|
||||||
return remove(key);
|
return remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return super.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean removeEldestEntry(Map.Entry<K, V> entry) {
|
protected boolean removeEldestEntry(Map.Entry<K, V> entry) {
|
||||||
return size() > maxCapacity;
|
return size() > maxCapacity;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user