NullSimpleResultAdapter extends AbstractResultAdapter<Object> { @Override public boolean accepts(Invocation invocation, Object originalValue) { final Class<?> returnType = invocation.getMethod().getReturnType(); return !Iterable.class.isAssignableFrom(returnType) && !Iterator.class.isAssignableFrom(returnType) && !Future.class.isAssignableFrom(returnType) && originalValue == null; } NullSimpleResultAdapter(); @Override boolean accepts(Invocation invocation, Object originalValue); @Override Object adapt(Invocation invocation, Object originalValue);  }
@Test public void testAcceptance() throws Exception { final NullSimpleResultAdapter adapter = new NullSimpleResultAdapter(); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findOther"), new Object[]{}), null), is(true)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findOther"), new Object[]{}), new Object()), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findList"), new Object[]{}), null), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findIterator"), new Object[]{}), null), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findFuture"), new Object[]{}), null), is(false)); }