Package org.jboss.marshalling
Class FieldSetter
- java.lang.Object
-
- org.jboss.marshalling.FieldSetter
-
public final class FieldSetter extends Object
A setter for a (possibly final) field, which allows for correct object initialization ofSerializableobjects withreadObject()methods, even in the presence offinalfields.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FieldSetterget(Class<?> clazz, String name)Get an instance for the current class.voidset(Object instance, Object value)Set the value of the field to the given object.voidsetBoolean(Object instance, boolean value)Set the value of the field to the given value.voidsetByte(Object instance, byte value)Set the value of the field to the given value.voidsetChar(Object instance, char value)Set the value of the field to the given value.voidsetDouble(Object instance, double value)Set the value of the field to the given value.voidsetFloat(Object instance, float value)Set the value of the field to the given value.voidsetInt(Object instance, int value)Set the value of the field to the given value.voidsetLong(Object instance, long value)Set the value of the field to the given value.voidsetShort(Object instance, short value)Set the value of the field to the given value.
-
-
-
Method Detail
-
set
public void set(Object instance, Object value) throws IllegalArgumentException
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
public void setBoolean(Object instance, boolean value) throws IllegalArgumentException
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
public void setByte(Object instance, byte value) throws IllegalArgumentException
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
public void setChar(Object instance, char value) throws IllegalArgumentException
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
public void setDouble(Object instance, double value) throws IllegalArgumentException
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
public void setFloat(Object instance, float value) throws IllegalArgumentException
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
public void setInt(Object instance, int value) throws IllegalArgumentException
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
public void setLong(Object instance, long value) throws IllegalArgumentException
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
public void setShort(Object instance, short value) throws IllegalArgumentException
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
-
-