There is an option in Eclipse (Preferences -> Java->Code Style)
It allows "is" Prefix for getters if the return is boolean.
My question why does it not do the prefixing if the return is the wrapper class (Boolean) ?
After you have created the variables in the class, right click, select Source, select Generate Getters and Setters.
This is simply because per the java beans specification/convention/implementation is prefix is only intended for primitive objects.
You can take a look at the PropertyDescriptor class source (getRealMethod):
if (readMethodName == null) {
Class type = getPropertyType0();
if (type == boolean.class || type == null) {
readMethodName = "is" + getBaseName();
} else {
readMethodName = "get" + getBaseName();
}
}
So eclipse is only conforming to this.
Edit: now why the property descriptor is made this way is another question, probably Java folks decided that the possibility of null return type and the "is" prefix may be misleading.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With