NullToCollectionResultAdapter extends AbstractResultAdapter<Collection> { @Override public boolean accepts(Invocation invocation, Object originalValue) { return originalValue == null && Collection.class.isAssignableFrom(invocation.getMethod().getReturnType()); } NullToCollectionResultAdapter(); @Override boolean accepts(Invocation invocation, Object originalValue); @Override Collection adapt(Invocation invocation, Object originalValue);  }
@Test public void testAcceptance() throws Exception { final ResultAdapter<Collection> adapter = new NullToCollectionResultAdapter(); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findList"), new Object[]{}), null), is(true)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findQueue"), new Object[]{}), null), is(true)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findSet"), new Object[]{}), null), is(true)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findLinkedList"), new Object[]{}), null), is(true)); }