Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [dali-dev] boolean getter method

Title: boolean getter method
The JavaBean spec[1] 8.3.2 says:

In addition, for boolean properties, we allow a getter method to match the pattern:

    public boolean is<PropertyName>();

This “is<PropertyName>” method may be provided instead of a “get<PropertyName>” method,
or it may be provided in addition to a “get<PropertyName>” method.

In either case, if the “is<PropertyName>” method is present for a boolean property then we will
use the “is<PropertyName>” method to read the property value.

An example boolean property might be:
    public boolean isMarsupial();
    public void setMarsupial(boolean m);


[1] http://java.sun.com/javase/technologies/desktop/javabeans/docs/spec.html

Paul Fullbright wrote:
Actually, I take that back.  I don't think we've done that for (big B) Boolean attributes.  Only (small b) boolean attributes.

- Paul


Paul Fullbright wrote:
My understanding is that for boolean (and Boolean) attributes, either "is" *or* "get" is acceptable.  We've always analyzed and generated code (to my recollection) with this understanding.

- Paul

Dimov, Stefan wrote:

Hi,

I've read some discussions about the signature of the accessor methods of an entity and I'm not certain if a getter with prefix 'get' is valid (in addition to the 'is' prefix). The EJB specification is also unclear (in my opinion) about this:

"… In this case, for every persistent property property of type T of the entity, there is a getter method, get-
Property, and setter method setProperty. For boolean properties, isProperty is an alternative name for
the getter method. …"

In other words, my question is:

For the getter method of an entity attributes of type 'boolean' is the only valid prefix 'is'  or the 'get' prefix is also allowed?



Back to the top