public class ReflectivePropertyOperator extends Object implements PropertyOperator
Implementation of PropertyOperator based on Java reflection.
Supports reading and writing JavaBean properties via Field or getter/setter methods.
supports:
This property operator can be used to handle the following scenarios:
throws exception:
If the specified property cannot find a Field or getter/setter method that supports read and write,
the operation will be aborted and null (if there is a return value) will be returned.
We can set throwIfNoAnyMatched to true to throw an exception in this case.
type conversion:
Setting ConverterManager, the class supports a certain degree of automatic conversion
of parameter types when writing property values.
| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
ReflectivePropertyOperator.ReflectivePropDesc
The reflection based property descriptor.
|
| 限定符和类型 | 字段和说明 |
|---|---|
protected @Nullable ConverterManager |
converterManager
converter register
|
static ReflectivePropertyOperator |
INSTANCE |
protected boolean |
throwIfNoAnyMatched
Whether to throw an exception if no matching method or field is found.
|
| 构造器和说明 |
|---|
ReflectivePropertyOperator()
Create a property operator.
|
ReflectivePropertyOperator(@Nullable ConverterManager converterManager)
Create a property operator.
|
| 限定符和类型 | 方法和说明 |
|---|---|
@NonNull PropDesc |
getPropertyDescriptor(Class<?> targetType)
Get property descriptor.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfindGetter, findSetter, readProperty, writePropertypublic static final ReflectivePropertyOperator INSTANCE
protected @Nullable ConverterManager converterManager
protected boolean throwIfNoAnyMatched
public ReflectivePropertyOperator(@Nullable ConverterManager converterManager)
converterManager - converter managerpublic ReflectivePropertyOperator()
public @NonNull PropDesc getPropertyDescriptor(Class<?> targetType)
getPropertyDescriptor 在接口中 PropertyOperatortargetType - target typeCopyright © 2024. All rights reserved.