The Java bean specification lacks details in some areas, and how to handle properties with an initial lower case letter followed by an upper case letter is one of those (i.e aProperty). The problem appears when trying to create a getter for a property like this. Should it be called getAProperty or getaProperty?
It turns out that best practice seems to be to call it getaProperty, because of the special handling of properties with two leading upper case letters (See section 8.8 in the specification). GetAProperty could translate to the (approved) property name AProperty, because if a name has two leading upper case letters they are left untouched. Unfortunately, not all tools handle this equally, so JAXB for example creates the getter getAProperty from a schema property aProperty, while jersey/jackson does it right, making interoperabililty difficult.
My recommendation therefore is to avoid this kind of naming alltogether, to avoid those problems.
It turns out that best practice seems to be to call it getaProperty, because of the special handling of properties with two leading upper case letters (See section 8.8 in the specification). GetAProperty could translate to the (approved) property name AProperty, because if a name has two leading upper case letters they are left untouched. Unfortunately, not all tools handle this equally, so JAXB for example creates the getter getAProperty from a schema property aProperty, while jersey/jackson does it right, making interoperabililty difficult.
My recommendation therefore is to avoid this kind of naming alltogether, to avoid those problems.
No comments:
Post a Comment