Skip to content

Commit 7f8102a

Browse files
committed
Merge branch '6.2.x'
2 parents e57464d + 6544698 commit 7f8102a

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

spring-core/src/main/java/org/springframework/util/CompositeMap.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import org.springframework.lang.Nullable;
2727

2828
/**
29-
* Composite map that combines two other maps. This type is created via
29+
* Composite map that combines two other maps.
30+
*
31+
* <p>This type is created via
3032
* {@link CollectionUtils#compositeMap(Map, Map, BiFunction, Consumer)}.
3133
*
3234
* @author Arjen Poutsma

spring-core/src/main/java/org/springframework/util/FilteredIterator.java

+9-15
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
import org.springframework.lang.Nullable;
2424

2525
/**
26-
* Iterator that filters out values that do not match a predicate.
27-
* This type is used by {@link CompositeMap}.
26+
* {@link Iterator} that filters out values that do not match a predicate.
27+
*
28+
* <p>This type is used by {@link CompositeMap}.
2829
*
2930
* @author Arjen Poutsma
3031
* @since 6.2
@@ -39,7 +40,7 @@ final class FilteredIterator<E> implements Iterator<E> {
3940
@Nullable
4041
private E next;
4142

42-
private boolean nextSet;
43+
private boolean hasNext;
4344

4445

4546
public FilteredIterator(Iterator<E> delegate, Predicate<E> filter) {
@@ -52,22 +53,15 @@ public FilteredIterator(Iterator<E> delegate, Predicate<E> filter) {
5253

5354
@Override
5455
public boolean hasNext() {
55-
if (this.nextSet) {
56-
return true;
57-
}
58-
else {
59-
return setNext();
60-
}
56+
return (this.hasNext || setNext());
6157
}
6258

6359
@Override
6460
public E next() {
65-
if (!this.nextSet) {
66-
if (!setNext()) {
67-
throw new NoSuchElementException();
68-
}
61+
if (!this.hasNext && !setNext()) {
62+
throw new NoSuchElementException();
6963
}
70-
this.nextSet = false;
64+
this.hasNext = false;
7165
Assert.state(this.next != null, "Next should not be null");
7266
return this.next;
7367
}
@@ -77,7 +71,7 @@ private boolean setNext() {
7771
E next = this.delegate.next();
7872
if (this.filter.test(next)) {
7973
this.next = next;
80-
this.nextSet = true;
74+
this.hasNext = true;
8175
return true;
8276
}
8377
}

0 commit comments

Comments
 (0)