Class CompiledStructureModifier
java.lang.Object
com.comphenix.protocol.reflect.StructureModifier<Object>
com.comphenix.protocol.reflect.compiler.CompiledStructureModifier
Represents a compiled structure modifier.
- Author:
- Kristian
-
Field Summary
FieldsFields inherited from class com.comphenix.protocol.reflect.StructureModifier
converter, customConvertHandling, data, defaultFields, fieldType, subtypeCache, target, targetType, useStructureCompiler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionread(int fieldIndex)Reads the value of a field given its index.protected abstract ObjectreadGenerated(int fieldIndex)protected ObjectreadReflected(int index)Read the given field index using reflection.voidsetReadOnly(int fieldIndex, boolean value)Set whether or not a field should be treated as read only.withTarget(Object target)Retrieves a structure modifier of the same type for a different object target.Writes the value of a field given its index.Sets all non-primitive fields to a more fitting default value.protected abstract StructureModifier<Object>writeGenerated(int index, Object value)protected voidwriteReflected(int index, Object value)Write the given field using reflection.Methods inherited from class com.comphenix.protocol.reflect.StructureModifier
getField, getFields, getFieldType, getFieldType, getTarget, getTargetType, getValues, initialize, initialize, initialize, isPublic, isReadOnly, modify, optionRead, readSafely, setConverter, setFinalState, size, toString, withFieldType, withFieldType, withParamType, withType, withType, writeSafely
-
Field Details
-
compiler
-
-
Constructor Details
-
CompiledStructureModifier
public CompiledStructureModifier()
-
-
Method Details
-
setReadOnly
Description copied from class:StructureModifierSet whether or not a field should be treated as read only.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.
- Overrides:
setReadOnlyin classStructureModifier<Object>- Parameters:
fieldIndex- - index of the field.value- - TRUE if this field should be read only, FALSE otherwise.- Throws:
FieldAccessException- If we cannot modify the read-only status.
-
writeDefaults
Description copied from class:StructureModifierSets all non-primitive fields to a more fitting default value. SeeDefaultInstances.getDefault(Class).- Overrides:
writeDefaultsin classStructureModifier<Object>- Returns:
- The current structure modifier - for chaining.
- Throws:
FieldAccessException- If we're unable to write to the fields due to a security limitation.
-
read
Description copied from class:StructureModifierReads the value of a field given its index.Note: This method is prone to exceptions (there are currently 5 total throw statements). It is recommended that you use
StructureModifier.readSafely(int), which returnsnullif the field doesn't exist, instead of throwing an exception.- Overrides:
readin classStructureModifier<Object>- Parameters:
fieldIndex- - index of the field.- Returns:
- Value of the field.
- Throws:
FieldAccessException- if the field doesn't exist, or it cannot be accessed under the current security contraints.
-
readReflected
Read the given field index using reflection.- Parameters:
index- - index of field.- Returns:
- Resulting value.
- Throws:
FieldAccessException- The field doesn't exist, or it cannot be accessed under the current security contraints.
-
readGenerated
- Throws:
FieldAccessException
-
write
Description copied from class:StructureModifierWrites the value of a field given its index.- Overrides:
writein classStructureModifier<Object>- Parameters:
index- - index of the field.value- - new value of the field.- Returns:
- This structure modifier - for chaining.
- Throws:
FieldAccessException- The field doesn't exist, or it cannot be accessed under the current security contraints.
-
writeReflected
Write the given field using reflection.- Parameters:
index- - index of field.value- - new value.- Throws:
FieldAccessException- The field doesn't exist, or it cannot be accessed under the current security contraints.
-
writeGenerated
protected abstract StructureModifier<Object> writeGenerated(int index, Object value) throws FieldAccessException- Throws:
FieldAccessException
-
withTarget
Description copied from class:StructureModifierRetrieves a structure modifier of the same type for a different object target.- Overrides:
withTargetin classStructureModifier<Object>- Parameters:
target- - different target of the same type.- Returns:
- Structure modifier with the new target.
-