Revise LinkedCaseInsensitiveMap's lazy key/value/entry collections
Closes gh-22926
This commit is contained in:
parent
60976e4116
commit
c8f20815ef
|
@ -56,13 +56,13 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
|
||||||
private final Locale locale;
|
private final Locale locale;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private transient Set<String> keySet;
|
private transient volatile Set<String> keySet;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private transient Collection<V> values;
|
private transient volatile Collection<V> values;
|
||||||
|
|
||||||
@Nullable
|
@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;
|
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();
|
this.delegate = targetMap.entrySet().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry<String, V> nextEntry() {
|
protected Entry<String, V> nextEntry() {
|
||||||
Entry<String, V> entry = this.delegate.next();
|
Entry<String, V> entry = this.delegate.next();
|
||||||
this.last = entry;
|
this.last = entry;
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return this.delegate.hasNext();
|
return this.delegate.hasNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
this.delegate.remove();
|
this.delegate.remove();
|
||||||
if (this.last != null) {
|
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
|
@Override
|
||||||
public String next() {
|
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
|
@Override
|
||||||
public V next() {
|
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
|
@Override
|
||||||
public Entry<String, V> next() {
|
public Entry<String, V> next() {
|
||||||
|
|
Loading…
Reference in New Issue