Package org.jboss.marshalling
Class FieldSetter
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static final class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldSetter
Get an instance for the current class.private IllegalStateException
void
Set the value of the field to the given object.void
setBoolean
(Object instance, boolean value) Set the value of the field to the given value.void
Set the value of the field to the given value.void
Set the value of the field to the given value.void
Set the value of the field to the given value.void
Set the value of the field to the given value.void
Set the value of the field to the given value.void
Set the value of the field to the given value.void
Set the value of the field to the given value.
-
Field Details
-
field
-
-
Constructor Details
-
FieldSetter
-
-
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 isnull
or 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 isnull
or 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 isnull
or 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 isnull
or 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 isnull
or 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 isnull
or 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 isnull
or 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 isnull
or 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 isnull
or not of the correct class
-
illegalState
-
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
Field
instance - 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
-