greenrobot / greenDAO

greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.
http://greenrobot.org/greendao/
12.63k stars 2.89k forks source link

Use method names that satisfy JavaBean conventions #660

Open Bringoff opened 7 years ago

Bringoff commented 7 years ago

Let's imagine we have the following class:

public class Item {
    private Long id;
    private boolean pending; // let's sync local changes with server later
}

I want to have getters and setters. Boolean getter should have name isPending, because it is boolean. But greenDAO expects only getPending as I see. My little perfectionist is crying inside, because it's ugly. I'm renaming pending field to isPending and have getIsPending getter, but it is still ugly. Is it possible to satisfy JavaBean getters naming conventions.

greenrobot-team commented 7 years ago

As far as I am aware, using the isX() pattern for boolean properties is optional and not required. Also you implied that the current method naming does work with JavaBeans, or is it broken?

Anyhow, leaving this open for future discussion and consideration. -ut

Bringoff commented 7 years ago

Well, it is not requirement, but in case when I already have some entities with getters and setters (and Android Studio generates getters for boolean with is prefix) and want to continue use them, I am not able to do this because greendao complains about lack of getters. So it may be nice to support both name patterns.