Class BeanPropertySetter


  • public class BeanPropertySetter
    extends java.lang.Object
    This utility class will call the setter of the property to inject a new value.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.Field field  
      private boolean reportNoSetterFound  
      private static java.lang.String SET_PREFIX  
      private java.lang.Object target  
    • Constructor Summary

      Constructors 
      Constructor Description
      BeanPropertySetter​(java.lang.Object target, java.lang.reflect.Field propertyField)
      New BeanPropertySetter that don't report failure
      BeanPropertySetter​(java.lang.Object target, java.lang.reflect.Field propertyField, boolean reportNoSetterFound)
      New BeanPropertySetter
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void reportNoSetterFound()  
      boolean set​(java.lang.Object value)
      Set the value to the property represented by this BeanPropertySetter
      private java.lang.String setterName​(java.lang.String fieldName)
      Retrieve the setter name from the field name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • target

        private final java.lang.Object target
      • reportNoSetterFound

        private final boolean reportNoSetterFound
      • field

        private final java.lang.reflect.Field field
    • Constructor Detail

      • BeanPropertySetter

        public BeanPropertySetter​(java.lang.Object target,
                                  java.lang.reflect.Field propertyField,
                                  boolean reportNoSetterFound)
        New BeanPropertySetter
        Parameters:
        target - The target on which the setter must be invoked
        propertyField - The field that should be accessed with the setter
        reportNoSetterFound - Allow the set method to raise an Exception if the setter cannot be found
      • BeanPropertySetter

        public BeanPropertySetter​(java.lang.Object target,
                                  java.lang.reflect.Field propertyField)
        New BeanPropertySetter that don't report failure
        Parameters:
        target - The target on which the setter must be invoked
        propertyField - The propertyField that must be accessed through a setter
    • Method Detail

      • set

        public boolean set​(java.lang.Object value)
        Set the value to the property represented by this BeanPropertySetter
        Parameters:
        value - the new value to pass to the property setter
        Returns:
        true if the value has been injected, false otherwise
        Throws:
        java.lang.RuntimeException - Can be thrown if the setter threw an exception, if the setter is not accessible or, if reportNoSetterFound and setter could not be found.
      • setterName

        private java.lang.String setterName​(java.lang.String fieldName)
        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()