On Thu, Oct 4, 2012 at 9:42 AM, Casper Bang <[email protected]> wrote:
> How do you guys handle callbacks with Void, say you really don't want
> anything returned because you are only consuming, streaming or the like?
>
> Say you have a generified callback for extracting rows from a dataset:
>
> public interface RowMapper[T]{
>     T map(Row row);
> }

I think the best you can do is an abstract class that hides the
"return null" for you.  So:

abstract class VoidRowMapper implements RowMapper<Void> {
   Void map(Row row) {
     voidMap(row);
     return null;
  }
  abstract void voidMap(Row row);
}

Then, you just do VoidMapper instead of RowMapper.  (And voidMap
instead of Map.)

I am interested in better ways.

-- 
You received this message because you are subscribed to the Google Groups "Java 
Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to