Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k views
in Technique[技术] by (71.8m points)

@data 和@builder 注解有啥用

   @Data
 @Builder(get = "")
    class god {
       private byte a=0;
       private java.lang.Byte ss() { return 2; }
    }
}
package com.company;
public @interface Builder {
    String get();
}
package com.company;
public @interface Data {
    byte parameter=10;
}

我再网上看到别人写的这种@data@bulider 但是不明白有什么用,求指教,谢谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

三段代码,第一段是对注解使用的描述,后两段是注解的定义,即标示注解有哪些成员
注解做了什么,取决于对应的注解处理器解析,通常结合反射及注解接口
@Data 为类提供读写功能,从而不用写get、set方法


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...