Class FieldSetter


  • public final class FieldSetter
    extends Object
    A setter for a (possibly final) field, which allows for correct object initialization of Serializable objects with readObject() methods, even in the presence of final fields.
    • Method Detail

      • setBoolean

        public void setBoolean​(Object instance,
                               boolean value)
                        throws IllegalArgumentException
        Set the value of the field to the given value.
        Parameters:
        instance - the instance to set
        value - the new value
        Throws:
        IllegalArgumentException - if the given instance is null or not of the correct class
      • setByte

        public void setByte​(Object instance,
                            byte value)
                     throws IllegalArgumentException
        Set the value of the field to the given value.
        Parameters:
        instance - the instance to set
        value - the new value
        Throws:
        IllegalArgumentException - if the given instance is null or not of the correct class
      • setChar

        public void setChar​(Object instance,
                            char value)
                     throws IllegalArgumentException
        Set the value of the field to the given value.
        Parameters:
        instance - the instance to set
        value - the new value
        Throws:
        IllegalArgumentException - if the given instance is null or not of the correct class
      • setDouble

        public void setDouble​(Object instance,
                              double value)
                       throws IllegalArgumentException
        Set the value of the field to the given value.
        Parameters:
        instance - the instance to set
        value - the new value
        Throws:
        IllegalArgumentException - if the given instance is null or not of the correct class
      • setFloat

        public void setFloat​(Object instance,
                             float value)
                      throws IllegalArgumentException
        Set the value of the field to the given value.
        Parameters:
        instance - the instance to set
        value - the new value
        Throws:
        IllegalArgumentException - if the given instance is null or not of the correct class
      • setInt

        public void setInt​(Object instance,
                           int value)
                    throws IllegalArgumentException
        Set the value of the field to the given value.
        Parameters:
        instance - the instance to set
        value - the new value
        Throws:
        IllegalArgumentException - if the given instance is null or not of the correct class
      • setLong

        public void setLong​(Object instance,
                            long value)
                     throws IllegalArgumentException
        Set the value of the field to the given value.
        Parameters:
        instance - the instance to set
        value - the new value
        Throws:
        IllegalArgumentException - if the given instance is null or not of the correct class
      • setShort

        public void setShort​(Object instance,
                             short value)
                      throws IllegalArgumentException
        Set the value of the field to the given value.
        Parameters:
        instance - the instance to set
        value - the new value
        Throws:
        IllegalArgumentException - if the given instance is null or not of the correct class