Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean fields prefixed with 'is' #12

Open
RubenJG opened this issue Feb 16, 2018 · 0 comments
Open

Boolean fields prefixed with 'is' #12

RubenJG opened this issue Feb 16, 2018 · 0 comments

Comments

@RubenJG
Copy link

RubenJG commented Feb 16, 2018

Hey, I found the following issue with IntelliJ (though it's not really an issue it's more like an inconvenience).

I had a class like this:

public class Test {

    private Boolean isTest;

    public Boolean getTest() {
        return isTest;
    }

    public void setTest(Boolean test) {
        isTest = test;
    }

    @Override
    public String toString() {
        return "Test{" +
                "isTest=" + isTest +
                '}';
    }
}

Notice that the getters and setters are named as getTest and setTest. This is how they were automatically generated.

When tested like this:

    assertThat(Test.class, allOf(
        hasValidBeanToString()
    ));

It fails with an error in which the most important part is It did not produce the property name "test"

I guess that a solution would be naming those methods like getIsTest and setIsTest and that's what I'm doing (because I want to keep the name prefixed since it is a DAO to a database table that I can't change), but it reads a little bit weirdly.

So I just wanted to leave this here, so that you might consider adding a special case for boolean fields named with an "is" prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant