public class ClassicBeanStyle extends BeanStyle
BeanStyle implementation that reflects beans of
traditional Java bean style as defined in the
Java Bean Specification.
For each property for a bean you basically have
void setZipCode(String c);
String getZipCode();
This bean style also exists with Optional support in
ClassicBeanStyleWithOptionalSupport.
| Modifier and Type | Field and Description |
|---|---|
static ClassicBeanStyle |
INSTANCE |
CLASSIC, CLASSIC_WITH_OPTIONAL, MODERN| Modifier | Constructor and Description |
|---|---|
protected |
ClassicBeanStyle() |
| Modifier and Type | Method and Description |
|---|---|
String |
convertGetterNameToFieldName(String getterName)
Cuts off "get" and decapitalizes the first character of the remaining.
|
String |
convertSetterNameToFieldName(String setterName)
Cuts off "set" and decapitalizes the first character of the remaining.
|
Class<?> |
determineFieldTypeFromGetterAndSetter(Class<?> beanType,
Method getterMethod,
Method setterMethod)
Determines the type of a bean field from given corresponding getter and
setter method.
|
protected boolean |
hasGetterMethodSignature(Method method) |
protected boolean |
hasSetterMethodSignature(Method method) |
boolean |
isGetterMethod(Method method)
Checks if the given method
does not return void
has no arguments
and has a name that has at least four characters and starts with
"get" or "is" for boolean properties
|
boolean |
isSetterMethod(Method method)
Checks if the given method
returns void
has exactly one arguments
and has a name that has at least four characters and starts with
"set"
|
assertForBeanType, equals, hashCode, isNoParameterInMethod, isOneParameterInMethodpublic static final ClassicBeanStyle INSTANCE
public boolean isGetterMethod(Method method)
isGetterMethod in class BeanStylemethod - the Method to testtrue if the method matches the requirements for a
getterBeanStyle.isGetterMethod(java.lang.reflect.Method)public boolean isSetterMethod(Method method)
isSetterMethod in class BeanStylemethod - the Method to testtrue if the method matches the requirements for a
setterBeanStyle.isSetterMethod(java.lang.reflect.Method)protected boolean hasGetterMethodSignature(Method method)
protected boolean hasSetterMethodSignature(Method method)
public String convertGetterNameToFieldName(String getterName)
convertGetterNameToFieldName in class BeanStylegetterName - the name of a method that has been identified as a potential
getterBeanStyle.convertGetterNameToFieldName(java.lang.String)public String convertSetterNameToFieldName(String setterName)
convertSetterNameToFieldName in class BeanStylesetterName - the name of a method that has been identified as a potential
setterBeanStyle.convertSetterNameToFieldName(java.lang.String)public Class<?> determineFieldTypeFromGetterAndSetter(Class<?> beanType, Method getterMethod, Method setterMethod) throws InvalidIBeanTypeException
BeanStyledetermineFieldTypeFromGetterAndSetter in class BeanStylebeanType - the examined bean classgetterMethod - a method of the beanType that is proven to be a
potential gettersetterMethod - a method of the beanType that is proven to be a
potential setterInvalidIBeanTypeException - if either the type cannot be determined for any reason or if
the concluded types of setter and getter do not match