diff src/goodjava/util/CacheMap.java @ 1607:fa066aaa068c

nginx caching
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 30 Apr 2021 20:23:28 -0600
parents 1b809d2fdf03
children
line wrap: on
line diff
--- a/src/goodjava/util/CacheMap.java	Tue Apr 20 18:06:50 2021 -0600
+++ b/src/goodjava/util/CacheMap.java	Fri Apr 30 20:23:28 2021 -0600
@@ -34,36 +34,36 @@
 		}
 	}
 
-	public int size() {
+	@Override public int size() {
 		return cache.size();
 	}
 
-	public boolean isEmpty() {
+	@Override public boolean isEmpty() {
 		return cache.isEmpty();
 	}
 
-	public boolean containsKey(Object key) {
+	@Override public boolean containsKey(Object key) {
 		return cache.containsKey(key);
 	}
 
-	public V get(Object key) {
+	@Override public V get(Object key) {
 		MyReference<K,V> ref = cache.get(key);
 		return ref==null ? null : ref.get();
 	}
 
-	public V put(K key,V value) {
+	@Override public V put(K key,V value) {
 		sweep();
 		MyReference<K,V> ref = cache.put( key, newReference(key,value,queue) );
 		return ref==null ? null : ref.get();
 	}
 
-	public V remove(Object key) {
+	@Override public V remove(Object key) {
 		sweep();
 		MyReference<K,V> ref = cache.remove(key);
 		return ref==null ? null : ref.get();
 	}
 
-	public void clear() {
+	@Override public void clear() {
 		sweep();
 		cache.clear();
 	}
@@ -75,43 +75,39 @@
 		return map;
 	}
 */
-	public Set<K> keySet() {
+	@Override public Set<K> keySet() {
 		return cache.keySet();
 	}
 
-	public Set<Map.Entry<K,V>> entrySet() {
+	@Override public Set<Map.Entry<K,V>> entrySet() {
 		return new MySet();
 	}
 
 
 	private class MySet extends AbstractSet<Map.Entry<K,V>> {
 
-		public int size() {
+		@Override public int size() {
 			return CacheMap.this.size();
 		}
 
-		public Iterator<Map.Entry<K,V>> iterator() {
-			return new MyIterator(cache.entrySet().iterator());
+		@Override public Iterator<Map.Entry<K,V>> iterator() {
+			return new MyIterator();
 		}
 
 	}
 
 	private class MyIterator implements Iterator<Map.Entry<K,V>> {
-		Iterator<Map.Entry<K,MyReference<K,V>>> iter;
+		final Iterator<Map.Entry<K,MyReference<K,V>>> iter = cache.entrySet().iterator();
 
-		MyIterator(Iterator<Map.Entry<K,MyReference<K,V>>> iter) {
-			this.iter = iter;
-		}
-
-		public boolean hasNext() {
+		@Override public boolean hasNext() {
 			return iter.hasNext();
 		}
 
-		public void remove() {
+		@Override public void remove() {
 			iter.remove();
 		}
 
-		public Map.Entry<K,V> next() {
+		@Override public Map.Entry<K,V> next() {
 			return new MyEntry( iter.next() );
 		}
 	}
@@ -123,21 +119,21 @@
 			this.entry = entry;
 		}
 
-		public K getKey() {
+		@Override public K getKey() {
 			return entry.getKey();
 		}
 
-		public V getValue() {
+		@Override public V getValue() {
 			MyReference<K,V> ref = entry.getValue();
 			return ref.get();
 		}
 
-		public V setValue(V value) {
+		@Override public V setValue(V value) {
 			MyReference<K,V> ref = entry.setValue( newReference(getKey(),value,queue) );
 			return ref.get();
 		}
 
-		public boolean equals(Object o) {
+		@Override public boolean equals(Object o) {
 			if( o==null || !(o instanceof CacheMap.MyEntry) )
 				return false;
 			@SuppressWarnings("unchecked")
@@ -145,7 +141,7 @@
 			return entry.equals(m.entry);
 		}
 
-		public int hashCode() {
+		@Override public int hashCode() {
 			K key = getKey();
 			V value = getValue();
 			return (key==null ? 0 : key.hashCode()) ^