@Override
  @SuppressWarnings("unchecked")
  public T answer(@Nonnull final InvocationOnMock invocation) throws Throwable {
    final Class<?> methodReturnType = invocation.getMethod().getReturnType();
    if (type.isAssignableFrom(methodReturnType) // fluent api methods
      || Query.class.isAssignableFrom(methodReturnType) // asc/desc
    ) {
      Object mock = invocation.getMock();
      return (T)mock ;
    }
    return null;
  }
@ Override @ SuppressWarnings ( "unchecked" ) public T answer ( @ Nonnull final InvocationOnMock invocation ) throws Throwable { final Class < ? > methodReturnType = invocation . getMethod ( ) . getReturnType ( ) ; if ( type . isAssignableFrom ( methodReturnType ) || Query . class . isAssignableFrom ( methodReturnType ) ) { Object mock = invocation . getMock ( ) ; return ( T ) mock ; } return null ; }
Returns the mock itself if return type and mock type match (assume fluent
api).

@param invocation
the method invocation. If its return type equals the mock type,
just return the mock.
@return the mock itself or null (meaning further stubbing is required).
@throws Throwable
when anything fails