public final class FieldSetter extends Object
Serializable
objects
with readObject()
methods, even in the presence of final
fields.Modifier and Type | Method and Description |
---|---|
static FieldSetter |
get(Class<?> clazz,
String name)
Get an instance for the current class.
|
void |
set(Object instance,
Object value)
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 |
setByte(Object instance,
byte value)
Set the value of the field to the given value.
|
void |
setChar(Object instance,
char value)
Set the value of the field to the given value.
|
void |
setDouble(Object instance,
double value)
Set the value of the field to the given value.
|
void |
setFloat(Object instance,
float value)
Set the value of the field to the given value.
|
void |
setInt(Object instance,
int value)
Set the value of the field to the given value.
|
void |
setLong(Object instance,
long value)
Set the value of the field to the given value.
|
void |
setShort(Object instance,
short value)
Set the value of the field to the given value.
|
public void set(Object instance, Object value) throws IllegalArgumentException
instance
- the instance to setvalue
- the new valueIllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setBoolean(Object instance, boolean value) throws IllegalArgumentException
instance
- the instance to setvalue
- the new valueIllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setByte(Object instance, byte value) throws IllegalArgumentException
instance
- the instance to setvalue
- the new valueIllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setChar(Object instance, char value) throws IllegalArgumentException
instance
- the instance to setvalue
- the new valueIllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setDouble(Object instance, double value) throws IllegalArgumentException
instance
- the instance to setvalue
- the new valueIllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setFloat(Object instance, float value) throws IllegalArgumentException
instance
- the instance to setvalue
- the new valueIllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setInt(Object instance, int value) throws IllegalArgumentException
instance
- the instance to setvalue
- the new valueIllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setLong(Object instance, long value) throws IllegalArgumentException
instance
- the instance to setvalue
- the new valueIllegalArgumentException
- if the given instance is null
or not of the correct classpublic void setShort(Object instance, short value) throws IllegalArgumentException
instance
- the instance to setvalue
- the new valueIllegalArgumentException
- if the given instance is null
or not of the correct classpublic static FieldSetter get(Class<?> clazz, String name) throws SecurityException, IllegalArgumentException
clazz
- the class containing the fieldname
- the name of the fieldField
instanceSecurityException
- 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 classCopyright © 2018 JBoss by Red Hat. All rights reserved.