I’d like to provide just a little more depth on what the spec says. It specifies how we get from the name of a getter and/or a setter to a property name. The interesting quote in this context is:
… to support the occasional use of all upper-case names, we check if
the first two characters of the name are both upper case and if so
leave it alone.
It’s from section 8.8: Capitalization of inferred names.
One example given is that URL
(as in getURL
or setURL
) becomes (or stays) URL
(not uRL
).
So the method names that you and I would have expected, getMGageProgram
and setMGageProgram
, would have implied a property named MGageProgram
with an upper case M
. Since we wanted mGageProgram
we need to use lower case m
in the names of the getter and the setter.
The rules as I read them thus really allow you to use a lowercase letter right after get
or set
in any getter or setter name. This came as a peculiar surprise to me. Of course it’s not an option that we want to exploit in cases where we don’t have to.
Link: JavaBeans Spec download page