Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 9584387

Browse files
committed
add pipe#map(class)
1 parent bce5135 commit 9584387

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • src/mutatio/main/java/org/comroid/mutatio/pipe

src/mutatio/main/java/org/comroid/mutatio/pipe/Pipe.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ default Pipe<O> filter(Predicate<? super O> predicate) {
107107
return addStage(StageAdapter.filter(predicate));
108108
}
109109

110+
default <R> Pipe<R> map(Class<R> target) {
111+
return filter(target::isInstance).map(target::cast);
112+
}
113+
110114
default <R> Pipe<R> map(Function<? super O, ? extends R> mapper) {
111115
return addStage(StageAdapter.map(mapper));
112116
}

0 commit comments

Comments
 (0)