crane4j icon indicating copy to clipboard operation
crane4j copied to clipboard

提供 `@AssembleExpression` 注解,从而支持基于表达式完成填充

Open Createsequence opened this issue 1 year ago • 0 comments

提供一个 @AssembleExpression 注解,用于基于表达式完成填充。比如:

public class Foo {

    @AssembleExpression(
        exp = "${config.properties.name}", // 指定表达式
        contextFactory = "springContextFactory", // 指定用于创建表达式上下文的工厂
        props = @Mapping(ref = "name") // 将值映射到 `name` 属性
    )
    private Integer value;
    private String name;
}

其中,对于 @AssembleExpression 注解:

  • 注解应当跟其他的标准注解一样,支持包括 sortprops 在内的各种标准属性;
  • 注解应当可以指定更换上下文工厂,从而支持在表达式中引用各种不同的上下文属性;

该功能可参考 @Assemble 注解与其对应的解析器 AssembleAnnotationHandler 完成。

Createsequence avatar Jul 11 '23 08:07 Createsequence