您好,欢迎访问一九零五行业门户网

java中Lombok有什么注解

注解举例
1、@tostring:实现tostring()方法
2、@data :注解在类上;提供类所有属性的 getting 和 setting 方法,此外还提供了equals、canequal、hashcode、tostring 方法
3、@setter:注解在属性上;为属性提供 setting 方法。@getter:注解在属性上;为属性提供 getting 方法
@log4j :注解在类上;为类提供一个 属性名为log 的 log4j 日志对象
@noargsconstructor:注解在类上;为类提供一个无参的构造方法
@allargsconstructor:注解在类上;为类提供一个全参的构造方法
@cleanup:关闭流
@tostring:实现tostring()方法
@equalsandhashcode:实现equals()方法和hashcode()方法
@synchronized:对象同步
@sneakythrows:抛出异常
实例
cleanup注释用于变量前,可确保该变量所代表的资源自动关闭,默认为close()调用资源。
public static void main(string[] args) throws ioexception {     @cleanup inputstream in = new fileinputstream(args[0]);     @cleanup outputstream out = new fileoutputstream(args[1]);     byte[] b = new byte[1024];     while (true) {       int r = in.read(b);       if (r == -1) break;       out.write(b, 0, r);     } }
以上就是java中lombok有什么注解的详细内容。
其它类似信息

推荐信息