feat(bean): 支持FastBeanCopier复制record#358
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
目的
5.0.x基准分支补齐 FastBeanCopier 对 Javarecord的复制支持。FastBeanCopier.copy(source, TargetRecord.class)无法构造目标对象的问题。Constructor#newInstance反射构造。核心变动
hsweb-core:RecordCopier,单独承载 record canonical constructor 复制契约,返回新 record 实例。Proxy机制生成RecordCopier实现,并通过RECORD_CACHE按 source/target 类型缓存。Map/ bean / record 源属性,按 record component 顺序调用 canonical constructor。Map -> record、bean -> record、record -> record、record -> bean、record -> Map。List<Record>泛型集合、primitive 默认值、非 primitive ignore 默认null、直接可赋值组件复用。FastBeanCopierTest#testRecordCopy,覆盖 Map/bean/record 与 nested record、集合泛型、ignore、缺省值等复制路径。设计与测试目标
5.0.x单独支持 record,并优先采用非每次 copy 反射构造方案。RecordCopier补充接口与方法契约说明;FastBeanCopier 中保留 record 不可变重建说明。测试结果
mvn -pl hsweb-core -Dtest=FastBeanCopierTest#testRecordCopy test1 passed, 0 failed, 0 skippedmvn -pl hsweb-core -Dtest=FastBeanCopierTest test14 passed, 0 failed, 0 skippedmvn -pl hsweb-core test62 passed, 0 failed, 0 skippedFastBeanCopierTest#testRecordCopy覆盖 Map/bean/record 与 nested record、集合泛型、ignore、缺省值复制路径。mvn -pl hsweb-core test后 JaCoCo):52.04%, branch49.52%FastBeanCopierline87.96%, branch76.15%文档同步情况
风险与说明
hsweb-core的 FastBeanCopier 复制和转换路径。RecordCopier契约说明;未破坏既有Copier原地写入契约。RecordCopier避免每次 copy 反射构造。