Class MethodAccessor
java.lang.Object
com.alibaba.fastjson2.introspect.MethodAccessor
- All Implemented Interfaces:
PropertyAccessor
Abstract base class for method-based property accessors.
Provides common functionality for accessing object properties using getter and setter methods.
This allows for accessing properties through standard getter/setter method pairs,
providing flexibility in how properties are accessed compared to direct field access.
Implements PropertyAccessor interface using method invocation for property access, providing efficient property access for serialization and deserialization operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MethodThe getter method for accessing the property valueprotected final StringThe name of the property being accessedprotected final Class<?> The runtime class of the propertyprotected final TypeThe generic type of the propertyprotected final MethodThe setter method for setting the property value -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal 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.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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
-
name
The name of the property being accessed -
propertyType
The generic type of the property -
propertyClass
The runtime class of the property -
getter
The getter method for accessing the property value -
setter
The setter method for setting the property value
-
-
Constructor Details
-
MethodAccessor
public MethodAccessor(String name, Type propertyType, Class<?> propertyClass, Method getter, Method setter) Constructs a MethodAccessor with the specified parameters.- Parameters:
name- the name of the propertypropertyType- the generic type of the propertypropertyClass- the runtime class of the propertygetter- the getter method for accessing the property valuesetter- the setter method for setting the property value
-
-
Method Details
-
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()Checks if the property supports getting values. A property supports getting if a getter method is provided.- Specified by:
supportGetin interfacePropertyAccessor- Returns:
- true if the getter method is not null, false otherwise
-
supportSet
public final boolean supportSet()Checks if the property supports setting values. A property supports setting if a setter method is provided.- Specified by:
supportSetin interfacePropertyAccessor- Returns:
- true if the setter method is not null, false otherwise
-
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
-