Class FieldAccessor
java.lang.Object
com.alibaba.fastjson2.introspect.FieldAccessor
- All Implemented Interfaces:
PropertyAccessor
Abstract base class for field-based property accessors.
Provides common functionality for accessing object fields using reflection.
Handles field metadata and determines if the field supports setting based
on whether the field is declared as final.
Implements PropertyAccessor interface using direct field access through reflection, providing efficient property access for serialization and deserialization operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FieldThe underlying Field object being accessedprotected final StringThe name of the fieldprotected final Class<?> The runtime class of the fieldprotected final TypeThe generic type of the fieldprotected final booleanFlag indicating whether the field supports setting values -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFieldAccessor(Field field) Constructs a FieldAccessor for the given field. -
Method Summary
Modifier and TypeMethodDescriptionfinal Fieldfield()Returns the underlying Field object.final Stringname()Returns the name of the property being accessed.final Class<?> Returns the runtime class of the property.final TypeReturns the generic type of the property.final booleanChecks if the property supports getting values.final booleanChecks if the property supports setting values.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface PropertyAccessor
getBooleanValue, getByteValue, getCharValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getObject, getShortValue, setBooleanValue, setByteValue, setCharValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setObject, setShortValue
-
Field Details
-
field
The underlying Field object being accessed -
fieldName
The name of the field -
propertyClass
The runtime class of the field -
propertyType
The generic type of the field -
supportSet
protected final boolean supportSetFlag indicating whether the field supports setting values
-
-
Constructor Details
-
FieldAccessor
Constructs a FieldAccessor for the given field.- Parameters:
field- the field to be accessed
-
-
Method Details
-
field
-
propertyClass
Description copied from interface:PropertyAccessorReturns the runtime class of the property.- Specified by:
propertyClassin interfacePropertyAccessor- Returns:
- the property class
-
propertyType
Description copied from interface:PropertyAccessorReturns the generic type of the property.- Specified by:
propertyTypein interfacePropertyAccessor- Returns:
- the property type
-
name
Description copied from interface:PropertyAccessorReturns the name of the property being accessed.- Specified by:
namein interfacePropertyAccessor- Returns:
- the property name
-
supportGet
public final boolean supportGet()Description copied from interface:PropertyAccessorChecks if the property supports getting values.- Specified by:
supportGetin interfacePropertyAccessor- Returns:
- true if the property can be read, false otherwise
-
supportSet
public final boolean supportSet()Description copied from interface:PropertyAccessorChecks if the property supports setting values.- Specified by:
supportSetin interfacePropertyAccessor- Returns:
- true if the property can be written, false otherwise
-
toString
-