#27 Support for getters of boolean variables



Right now Super CSV only searches for getter methods that start with 'get', such as getX(). However, boolean member variables usually have getters of the form isX(). We should add support for this. I could create a small patch that changes the behaviour as follows: for a x variable, it tries to find a getX() method, and if it cannot find it, it also tries the isX() method. This would be also backward compatible.


  • James Bassett

    James Bassett - 2013-02-25

    Yes, I think this is a good feature. The CsvDozerBeanWriter already supports this (as Dozer does), but CsvBeanWriter doesn't.

    Note that isX() is only valid for boolean/Boolean fields - we probably shouldn't match isX() accessors for all types (if somebody makes a typo on a field name, we really don't want the exception to say that it couldn't find isX() when the field might actually be a String/Integer).

    Go for it :)

  • James Bassett

    James Bassett - 2013-02-27

    Awesome, thanks Vlad, it's good to see that feature implemented. I've applied the patch and added you as a contributor to the project :) I did end up modifying it a fair bit to make it more robust (ensuring there's a return type and no parameters on the getter).

    I now realise why we didn't add it sooner - ideally we should also add support for isX() style boolean getters to BeanInterfaceProxy (if you read into an interface instead of a class), and that's a lot more complicated (particularly when there's getters returning primitives, which it doesn't support yet). But I'll raise a separate feature request for that, as it's probably not a widely used feature.



    Commit: [r276]

  • James Bassett

    James Bassett - 2013-03-01
    • status: open --> pending
    • milestone: Outstanding --> 2.1.0
  • James Bassett

    James Bassett - 2013-04-24
    • Status: pending --> closed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks