首页 > 解决方案 > 当其他字段具有特定值时需要注释字段

问题描述

如果我有这样定义的字段注释:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface  LineField {
    public int at();
    public int length();
    public String literal() default "[unassigned]";
    public boolean isId() default false;

}

当 'isId' 设置为 true 时,api 本身是否有可能让 'literal' 不是可选的,

例子 :

//Valid
    @LineField(at = 0, length = 1, isId = true, literal = "6")
    private String recordTypeCode;

//Invalid
      @LineField(at = 0, length = 1, isId = true)
    private String recordTypeCode;

标签: javaspringannotationsannotation-processing

解决方案


推荐阅读