Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

简化属性映射配置,支持通过字面量的形式配置 #230

Closed
Createsequence opened this issue Mar 14, 2024 · 0 comments
Closed
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Createsequence
Copy link
Collaborator

参见 BeanKeyResoler,支持使用带分隔符的字符串简化属性映射配置,比如:

@Assemble(
    container = "user", 
    props = { @Mapping(src = "a", ref = "b"), @Mapping(src = "c", ref = "d"), @Mapping("e") }
)
private Integer id;

该配置可简化为:

@Assemble(
    container = "user", prop = "a:b, c:d, e"
)
private Integer id;

@Assemble(
    container = "user", prop = { "a:b", "c:d", "e" }
)
private Integer id;

基于字符串的属性映射规则与 @Mapping 注解保持语义上的一致:

  • a:b 等同于 @Mapping(src = "a", ref = "b")
  • a: 等同于 @Mapping(src = "a")
  • :b 等同于 @Mapping(ref = "b")
  • a 等同于 @Mapping("a")

此部分功能后续可考虑抽离为独立组件完成,从而支持一定程度上的自定义。

@Createsequence Createsequence self-assigned this Mar 14, 2024
@Createsequence Createsequence added the enhancement New feature or request label Mar 14, 2024
@Createsequence Createsequence added this to the release 2.7.0 milestone Mar 14, 2024
@Createsequence Createsequence changed the title 简化属性映射配置 简化属性映射配置,支持通过字面量的形式配置 Mar 18, 2024
Createsequence added a commit that referenced this issue Mar 29, 2024
Createsequence added a commit that referenced this issue Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant