Annotation Interface DictModel
When the framework processes a response object, it recursively scans the object structure to look for fields annotated with DictDesc, and fills in the internationalized text.
To avoid unnecessary deep recursion and field scanning, the framework checks at the type judgment stage whether the class is annotated with @DictModel,
so that it can quickly decide whether the class may contain fields that need processing, thereby improving overall processing performance.
Note: Annotating with @DictModel is not a prerequisite for recursion. The framework will always perform recursive scanning,
The main reason for this is that in many scenarios, it's not possible to add annotations for all returned types, such as when using third-party types that cannot be modified.
but adding this annotation helps the framework hit the cache early, avoiding deep analysis of unnecessary class structures.
Example:
@DictModel
public class Address {
private String regionType;
@DictDesc(RegionDict.class)
private String regionTypeDesc;
}
public class UserInfo {
private String name;
// The 'address' will be recursively processed, and performance is better because 'Address' is annotated with @DictModel
private Address address;
}
Recommended: For any class that contains other possible classes with dictionary fields, it is recommended to annotate the nested type with @DictModel.
- 另请参阅: