java.lang.Object
org.jboss.marshalling.FieldSetter
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 Summary
Modifier and TypeMethodDescriptionstatic FieldSetterGet an instance for the current class.voidSet the value of the field to the given object.voidsetBoolean(Object instance, boolean value) Set the value of the field to the given value.voidSet the value of the field to the given value.voidSet the value of the field to the given value.voidSet the value of the field to the given value.voidSet the value of the field to the given value.voidSet the value of the field to the given value.voidSet the value of the field to the given value.voidSet the value of the field to the given value.
-
Method Details
-
set
Set the value of the field to the given object.- Parameters:
instance- the instance to setvalue- the new value- Throws:
IllegalArgumentException- if the given instance isnullor not of the correct class
-
setBoolean
Set the value of the field to the given value.- Parameters:
instance- the instance to setvalue- the new value- Throws:
IllegalArgumentException- if the given instance isnullor not of the correct class
-
setByte
Set the value of the field to the given value.- Parameters:
instance- the instance to setvalue- the new value- Throws:
IllegalArgumentException- if the given instance isnullor not of the correct class
-
setChar
Set the value of the field to the given value.- Parameters:
instance- the instance to setvalue- the new value- Throws:
IllegalArgumentException- if the given instance isnullor not of the correct class
-
setDouble
Set the value of the field to the given value.- Parameters:
instance- the instance to setvalue- the new value- Throws:
IllegalArgumentException- if the given instance isnullor not of the correct class
-
setFloat
Set the value of the field to the given value.- Parameters:
instance- the instance to setvalue- the new value- Throws:
IllegalArgumentException- if the given instance isnullor not of the correct class
-
setInt
Set the value of the field to the given value.- Parameters:
instance- the instance to setvalue- the new value- Throws:
IllegalArgumentException- if the given instance isnullor not of the correct class
-
setLong
Set the value of the field to the given value.- Parameters:
instance- the instance to setvalue- the new value- Throws:
IllegalArgumentException- if the given instance isnullor not of the correct class
-
setShort
Set the value of the field to the given value.- Parameters:
instance- the instance to setvalue- the new value- Throws:
IllegalArgumentException- if the given instance isnullor not of the correct class
-
get
public static FieldSetter get(Class<?> clazz, String name) throws SecurityException, IllegalArgumentException Get an instance for the current class.- Parameters:
clazz- the class containing the fieldname- the name of the field- Returns:
- the
Fieldinstance - Throws:
SecurityException- if the field does not belong to the caller's class, or the field is staticIllegalArgumentException- if there is no field of the given name on the given class
-