public class JavaBeanPropertyStyleConfig extends BaseTraitStyleConfig
Constructor and Description |
---|
JavaBeanPropertyStyleConfig() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object that) |
protected ClassLoader |
getAdditionalClassLoader() |
protected String[] |
getExcludeName() |
protected MessageFormat |
getPrivateFieldConvention() |
int |
hashCode() |
protected boolean |
isSupportPublicFields() |
JavaBeanPropertyStyleConfig |
setAdditionalClassLoader(ClassLoader additionalClassLoader)
Sets an additional ClassLoader to use to resolve classes.
|
JavaBeanPropertyStyleConfig |
setExcludeName(String... excludeName)
Overridden to exclude the names 'propertyChangeListeners' and 'vetoableChangeListeners' by
default.
|
JavaBeanPropertyStyleConfig |
setPrivateFieldConvention(MessageFormat privateFieldConvention)
Sets the naming convention used to identify the private field, given the property
name.
|
JavaBeanPropertyStyleConfig |
setSupportPublicFields(boolean supportPublicFields)
Sets whether to recognize public fields as properties.
|
getExcludeBaseType, getExcludeReturnType, isCacheLookups, setCacheLookups, setExcludeBaseType, setExcludeReturnType
public JavaBeanPropertyStyleConfig setExcludeName(String... excludeName)
setExcludeName
in class BaseTraitStyleConfig
excludeName
- list of names to consider for exclusionpublic JavaBeanPropertyStyleConfig setSupportPublicFields(boolean supportPublicFields)
public JavaBeanPropertyStyleConfig setPrivateFieldConvention(MessageFormat privateFieldConvention)
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:
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!
public JavaBeanPropertyStyleConfig setAdditionalClassLoader(ClassLoader additionalClassLoader)
This can be useful if using JavaBeanPropertyStyle
outside of Metawidget. For
example, you use a JavaBeanPropertyStyle
in your EJB layer, but pass it a type
String that refers to a class from the WAR layer. In order to resolve that type, the EJB
layer must use the WAR layer's ClassLoader.
public boolean equals(Object that)
equals
in class BaseTraitStyleConfig
public int hashCode()
hashCode
in class BaseTraitStyleConfig
protected String[] getExcludeName()
getExcludeName
in class BaseTraitStyleConfig
protected boolean isSupportPublicFields()
protected MessageFormat getPrivateFieldConvention()
protected ClassLoader getAdditionalClassLoader()
Copyright © 2015. All Rights Reserved.