public class JavaBeanPropertyStyle extends BasePropertyStyle
This PropertyStyle recognizes getters and setters declared using the JavaBean convention.
Please note:
JavaBeanPropertyStyleConfig.setSupportPublicFields
java.beans.Introspector
, as some environments
that use JavaBean-convention do not support the java.bean
package (eg. Android)JavaBeanPropertyStyleConfig.setPrivateFieldConvention
Modifier and Type | Class and Description |
---|---|
static class |
JavaBeanPropertyStyle.FieldProperty
Public member field-based property.
|
static class |
JavaBeanPropertyStyle.JavaBeanProperty
JavaBean-convention-based property.
|
mLog
Constructor and Description |
---|
JavaBeanPropertyStyle() |
JavaBeanPropertyStyle(JavaBeanPropertyStyleConfig config) |
Modifier and Type | Method and Description |
---|---|
protected Field |
getPrivateField(Class<?> clazz,
String propertyName)
Gets the private field representing the given
propertyName within the given
class. |
protected Map<String,Property> |
inspectProperties(String type)
Returns properties sorted by name.
|
protected String |
isGetter(Method method)
Returns whether the given method is a 'getter' method.
|
protected String |
isSetter(Method method)
Returns whether the given method is a 'setter' method.
|
protected void |
lookupFields(Map<String,Property> properties,
Class<?> clazz)
Lookup public field-based properties.
|
protected void |
lookupGetters(Map<String,Property> properties,
Class<?> clazz)
Lookup getter-based properties.
|
protected void |
lookupSetters(Map<String,Property> properties,
Class<?> clazz)
Lookup setter-based properties.
|
getProperties, getUncachedTraits, traverse
cacheTraits, clearCache, getCachedTraits, getTraits, isExcluded, isExcludedBaseType, isExcludedName, isExcludedReturnType
public JavaBeanPropertyStyle()
public JavaBeanPropertyStyle(JavaBeanPropertyStyleConfig config)
protected Map<String,Property> inspectProperties(String type)
inspectProperties
in class BasePropertyStyle
protected void lookupFields(Map<String,Property> properties, Class<?> clazz)
This method will be called before lookupGetters
and lookupSetters
.
protected void lookupGetters(Map<String,Property> properties, Class<?> clazz)
This method will be called after lookupFields
but before
lookupSetters
.
protected String isGetter(Method method)
method
- a parameterless method that returns a non-voidprotected void lookupSetters(Map<String,Property> properties, Class<?> clazz)
This method will be called after lookupFields
and lookupGetters
.
protected String isSetter(Method method)
method
- a single-parametered method. May return non-void (ie. for Fluent interfaces)protected Field getPrivateField(Class<?> clazz, String propertyName)
propertyName
within the given
class. Uses the configured privateFieldConvention
(if any). Traverses up the
superclass heirarchy as necessary.
Note it is not considered an error if a property has no corresponding private field:
not all properties do. For example a property getAge
may be calculated
internally based off a mDateOfBirth
field, with no corresponding
mAge
field per se.
Clients may override this method to change how the public-method-to-private-field mapping operates.
Copyright © 2015. All Rights Reserved.