Skip to content

Commit e664b14

Browse files
committed
reuse existing
1 parent 704a126 commit e664b14

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/one/util/streamex/EntryStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ public <KK> EntryStream<KK, V> mapKeys(Function<? super K, ? extends KK> keyMapp
507507
*
508508
*/
509509
public <KK> EntryStream<KK, V> mapKeysPartial(Function<? super K, ? extends Optional<? extends KK>> keyMapper) {
510-
return new EntryStream<>(stream().map(e -> new SimpleImmutableEntry<>((KK) keyMapper.apply(e.getKey()).orElse(null), e.getValue())).filter(e -> e.getKey() != null), context);
510+
return mapToKeyPartial((k, _v) -> keyMapper.apply(k));
511511
}
512512

513513
/**
@@ -558,7 +558,7 @@ public <VV> EntryStream<K, VV> mapValues(Function<? super V, ? extends VV> value
558558
* @since 0.8.4
559559
*/
560560
public <VV> EntryStream<K, VV> mapValuesPartial(Function<? super V, ? extends Optional<? extends VV>> valueMapper) {
561-
return new EntryStream<>(stream().map(e -> new SimpleImmutableEntry<>(e.getKey(), (VV) valueMapper.apply(e.getValue()).orElse(null))).filter(e -> e.getValue() != null), context);
561+
return mapToValuePartial((_k, v) -> valueMapper.apply(v));
562562
}
563563

564564
/**

0 commit comments

Comments
 (0)