Sets the naming convention used to identify the private field, given the property
name.
The JavaBean specification does not establish a relationship between getters/setters and
their private fields. This is because some getters/setters will not be simple one-to-one
mappings. For example, a getAge
method may calculate itself based off a
mDateOfBirth
field, rather than an mAge
field.
However, it is a common requirement to want to annotate the private field rather
than its getter/setter. Frameworks like JPA allow this because they can populate the private
field directly. This does not work well for Metawidget because most UI frameworks, including
binding and validation frameworks, rely on public getters/setters.
To support the best of both worlds, JavaBeanPropertyStyle
can attempt to map a
getter/setter to its private field if given the naming convention to use. The naming
convention is specified as a MessageFormat
. Some examples:
- {0} = dateOfBirth, surname
- 'm'{1} = mDateOfBirth, mSurname
- 'm_'{0} = m_dateOfBirth, m_surname
This mapping will fail silently in cases where there is no private field. It will also fail
silently if the private field name is misspelt, so be careful!