public final class FieldSetter
extends java.lang.Object
Serializable
objects
with readObject()
methods, even in the presence of final
fields.Modifier and Type | Method and Description |
---|---|
static FieldSetter |
get(java.lang.Class<?> clazz,
java.lang.String name)
Get an instance for the current class.
|
void |
set(java.lang.Object instance,
java.lang.Object value)
Set the value of the field to the given object.
|
void |
setBoolean(java.lang.Object instance,
boolean value)
Set the value of the field to the given value.
|
void |
setByte(java.lang.Object instance,
byte value)
Set the value of the field to the given value.
|
void |
setChar(java.lang.Object instance,
char value)
Set the value of the field to the given value.
|
void |
setDouble(java.lang.Object instance,
double value)
Set the value of the field to the given value.
|
void |
setFloat(java.lang.Object instance,
float value)
Set the value of the field to the given value.
|
void |
setInt(java.lang.Object instance,
int value)
Set the value of the field to the given value.
|
void |
setLong(java.lang.Object instance,
long value)
Set the value of the field to the given value.
|
void |
setShort(java.lang.Object instance,
short value)
Set the value of the field to the given value.
|
public void set(java.lang.Object instance, java.lang.Object value) throws java.lang.IllegalArgumentException
instance
- the instance to setvalue
- the new valuejava.lang.IllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setBoolean(java.lang.Object instance, boolean value) throws java.lang.IllegalArgumentException
instance
- the instance to setvalue
- the new valuejava.lang.IllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setByte(java.lang.Object instance, byte value) throws java.lang.IllegalArgumentException
instance
- the instance to setvalue
- the new valuejava.lang.IllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setChar(java.lang.Object instance, char value) throws java.lang.IllegalArgumentException
instance
- the instance to setvalue
- the new valuejava.lang.IllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setDouble(java.lang.Object instance, double value) throws java.lang.IllegalArgumentException
instance
- the instance to setvalue
- the new valuejava.lang.IllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setFloat(java.lang.Object instance, float value) throws java.lang.IllegalArgumentException
instance
- the instance to setvalue
- the new valuejava.lang.IllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setInt(java.lang.Object instance, int value) throws java.lang.IllegalArgumentException
instance
- the instance to setvalue
- the new valuejava.lang.IllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setLong(java.lang.Object instance, long value) throws java.lang.IllegalArgumentException
instance
- the instance to setvalue
- the new valuejava.lang.IllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setShort(java.lang.Object instance, short value) throws java.lang.IllegalArgumentException
instance
- the instance to setvalue
- the new valuejava.lang.IllegalArgumentException
- if the given instance is null
or not of the correct classpublic static FieldSetter get(java.lang.Class<?> clazz, java.lang.String name) throws java.lang.SecurityException, java.lang.IllegalArgumentException
clazz
- the class containing the fieldname
- the name of the fieldField
instancejava.lang.SecurityException
- if the field does not belong to the caller's class, or the field is staticjava.lang.IllegalArgumentException
- if there is no field of the given name on the given classCopyright © 2011 JBoss, a division of Red Hat, Inc.