Class BeanPropertySetter
java.lang.Object
org.mockito.internal.util.reflection.BeanPropertySetter
This utility class will call the setter of the property to inject a new value.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBeanPropertySetter(Object target, Field propertyField) New BeanPropertySetter that don't report failureBeanPropertySetter(Object target, Field propertyField, boolean reportNoSetterFound) New BeanPropertySetter -
Method Summary
Modifier and TypeMethodDescriptionprivate voidbooleanSet the value to the property represented by thisBeanPropertySetterprivate StringsetterName(String fieldName) Retrieve the setter name from the field name.
-
Field Details
-
SET_PREFIX
- See Also:
-
target
-
reportNoSetterFound
private final boolean reportNoSetterFound -
field
-
-
Constructor Details
-
BeanPropertySetter
New BeanPropertySetter- Parameters:
target- The target on which the setter must be invokedpropertyField- The field that should be accessed with the setterreportNoSetterFound- Allow the set method to raise an Exception if the setter cannot be found
-
BeanPropertySetter
New BeanPropertySetter that don't report failure- Parameters:
target- The target on which the setter must be invokedpropertyField- The propertyField that must be accessed through a setter
-
-
Method Details
-
set
Set the value to the property represented by thisBeanPropertySetter- Parameters:
value- the new value to pass to the property setter- Returns:
trueif the value has been injected,falseotherwise- Throws:
RuntimeException- Can be thrown if the setter threw an exception, if the setter is not accessible or, ifreportNoSetterFoundand setter could not be found.
-
setterName
Retrieve the setter name from the field name.Implementation is based on the code of
Introspector.- Parameters:
fieldName- the Field name- Returns:
- Setter name.
-
reportNoSetterFound
private void reportNoSetterFound()
-