Well, the general convention is to use get... and set... , and thus is... is just an exception for booleans. For is... convention is easy: you need to return a boolean, you can skip the getter, and the corresponding typesetter will also accept the boolean parameter.
Aligning for has... will be more complicated: has... will return a boolean, but you still need getter and setter, which deal with different types. Thus, has... does not replace get... unlike is... , and since this part of the JavaBeans convention, as a rule, applies only to hasters and setters, has... does not fit there.
From the JavaBeans specification:
Properties are discrete, named Java Bean attributes ...
Properties are displayed in several ways:
- ...
- Access to properties is possible programmatically with the help of other components that call them and configuration methods (see section 7.1 below).
- ...
Any property accessed using has... will not be permanent and will not be accessible by its getter method.
Example: if a person has a car property, you must have the getCar() accessory. hasCar() will not be an accessory because the hasCar derived property needs an accessor named getHasCar() or isHasCar() . If has was an access prefix, the property has the inconsistent name car .
Thomas
source share