Closes gh-11788
pull/11772/merge
Stephane Nicoll 7 years ago
parent c8c6e0f195
commit 1880a25cfb

@ -264,7 +264,7 @@ public final class PropertyMapper {
* @param target the target type to match * @param target the target type to match
* @return a new filtered source instance * @return a new filtered source instance
*/ */
public <R> Source<R> whenInstanceOf(Class<R> target) { public <R extends T> Source<R> whenInstanceOf(Class<R> target) {
return when(target::isInstance).as(target::cast); return when(target::isInstance).as(target::cast);
} }

@ -151,7 +151,8 @@ public class PropertyMapperTests {
@Test @Test
public void whenInstanceOfWhenValueIsNotTargetTypeShouldNotMatch() { public void whenInstanceOfWhenValueIsNotTargetTypeShouldNotMatch() {
this.map.from(() -> 123).whenInstanceOf(Double.class).toCall(Assert::fail); this.map.from(() -> (Number) 123L).whenInstanceOf(Double.class)
.toCall(Assert::fail);
} }
@Test @Test

Loading…
Cancel
Save