public abstract class CompiledStructureModifier extends StructureModifier<java.lang.Object>
Modifier and Type | Field and Description |
---|---|
protected StructureCompiler |
compiler |
converter, customConvertHandling, data, defaultFields, fieldType, subtypeCache, target, targetType, useStructureCompiler
Constructor and Description |
---|
CompiledStructureModifier() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
read(int fieldIndex)
Reads the value of a field given its index.
|
protected abstract java.lang.Object |
readGenerated(int fieldIndex) |
protected java.lang.Object |
readReflected(int index)
Read the given field index using reflection.
|
void |
setReadOnly(int fieldIndex,
boolean value)
Set whether or not a field should be treated as read only.
|
StructureModifier<java.lang.Object> |
withTarget(java.lang.Object target)
Retrieves a structure modifier of the same type for a different object target.
|
StructureModifier<java.lang.Object> |
write(int index,
java.lang.Object value)
Writes the value of a field given its index.
|
StructureModifier<java.lang.Object> |
writeDefaults()
Sets all non-primitive fields to a more fitting default value.
|
protected abstract StructureModifier<java.lang.Object> |
writeGenerated(int index,
java.lang.Object value) |
protected void |
writeReflected(int index,
java.lang.Object value)
Write the given field using reflection.
|
getField, getFields, getFieldType, getFieldType, getTarget, getTargetType, getValues, initialize, initialize, initialize, isPublic, isReadOnly, modify, readSafely, setConverter, setFinalState, size, withFieldType, withType, withType, writeSafely
protected StructureCompiler compiler
public void setReadOnly(int fieldIndex, boolean value) throws FieldAccessException
StructureModifier
Note that changing the read-only state to TRUE will only work if the current field was recently read-only or the current structure modifier hasn't been compiled yet.
setReadOnly
in class StructureModifier<java.lang.Object>
fieldIndex
- - index of the field.value
- - TRUE if this field should be read only, FALSE otherwise.FieldAccessException
- If we cannot modify the read-only status.public StructureModifier<java.lang.Object> writeDefaults() throws FieldAccessException
StructureModifier
DefaultInstances.getDefault(Class)
.writeDefaults
in class StructureModifier<java.lang.Object>
FieldAccessException
- If we're unable to write to the fields due to a security limitation.public final java.lang.Object read(int fieldIndex) throws FieldAccessException
StructureModifier
read
in class StructureModifier<java.lang.Object>
fieldIndex
- - index of the field.FieldAccessException
- The field doesn't exist, or it cannot be accessed under the current security contraints.protected java.lang.Object readReflected(int index) throws FieldAccessException
index
- - index of field.FieldAccessException
- The field doesn't exist, or it cannot be accessed under the current security contraints.protected abstract java.lang.Object readGenerated(int fieldIndex) throws FieldAccessException
FieldAccessException
public StructureModifier<java.lang.Object> write(int index, java.lang.Object value) throws FieldAccessException
StructureModifier
write
in class StructureModifier<java.lang.Object>
index
- - index of the field.value
- - new value of the field.FieldAccessException
- The field doesn't exist, or it cannot be accessed under the current security contraints.protected void writeReflected(int index, java.lang.Object value) throws FieldAccessException
index
- - index of field.value
- - new value.FieldAccessException
- The field doesn't exist, or it cannot be accessed under the current security contraints.protected abstract StructureModifier<java.lang.Object> writeGenerated(int index, java.lang.Object value) throws FieldAccessException
FieldAccessException
public StructureModifier<java.lang.Object> withTarget(java.lang.Object target)
StructureModifier
withTarget
in class StructureModifier<java.lang.Object>
target
- - different target of the same type.