Revise LinkedCaseInsensitiveMap's lazy key/value/entry collections
Closes gh-22926
This commit is contained in:
committed by
Sam Brannen
parent
60976e4116
commit
c8f20815ef
@@ -56,13 +56,13 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
|
||||
private final Locale locale;
|
||||
|
||||
@Nullable
|
||||
private transient Set<String> keySet;
|
||||
private transient volatile Set<String> keySet;
|
||||
|
||||
@Nullable
|
||||
private transient Collection<V> values;
|
||||
private transient volatile Collection<V> values;
|
||||
|
||||
@Nullable
|
||||
private transient Set<Entry<String, V>> entrySet;
|
||||
private transient volatile Set<Entry<String, V>> entrySet;
|
||||
|
||||
|
||||
/**
|
||||
@@ -465,7 +465,7 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
|
||||
}
|
||||
|
||||
|
||||
private class EntryIterator {
|
||||
private abstract class EntryIterator<T> implements Iterator<T> {
|
||||
|
||||
private final Iterator<Entry<String, V>> delegate;
|
||||
|
||||
@@ -476,16 +476,18 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
|
||||
this.delegate = targetMap.entrySet().iterator();
|
||||
}
|
||||
|
||||
public Entry<String, V> nextEntry() {
|
||||
protected Entry<String, V> nextEntry() {
|
||||
Entry<String, V> entry = this.delegate.next();
|
||||
this.last = entry;
|
||||
return entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return this.delegate.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
this.delegate.remove();
|
||||
if (this.last != null) {
|
||||
@@ -496,7 +498,7 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
|
||||
}
|
||||
|
||||
|
||||
private class KeySetIterator extends EntryIterator implements Iterator<String> {
|
||||
private class KeySetIterator extends EntryIterator<String> {
|
||||
|
||||
@Override
|
||||
public String next() {
|
||||
@@ -505,7 +507,7 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
|
||||
}
|
||||
|
||||
|
||||
private class ValuesIterator extends EntryIterator implements Iterator<V> {
|
||||
private class ValuesIterator extends EntryIterator<V> {
|
||||
|
||||
@Override
|
||||
public V next() {
|
||||
@@ -514,7 +516,7 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
|
||||
}
|
||||
|
||||
|
||||
private class EntrySetIterator extends EntryIterator implements Iterator<Entry<String, V>> {
|
||||
private class EntrySetIterator extends EntryIterator<Entry<String, V>> {
|
||||
|
||||
@Override
|
||||
public Entry<String, V> next() {
|
||||
|
||||
Reference in New Issue
Block a user