标签:style http java color 使用 os
lombok 注解:@AllArgsConstructor:注解在类上;为类提供一个全参的构造方法
下面是简单示例 1.不使用 lombok 的方案 1 2public class Person { 3 4 private String id; 5 private String name; 6 private String identity; 7 private Logger log = Logger.getLogger(Person.class); 8 9 public Person() { 10 11 } 12 13 public Person(String id, String name, String identity) { 14 this.id = id; 15 this.name = name; 16 this.identity = identity; 17 } 18 19 public String getId() { 20 return id; 21 } 22 23 public String getName() { 24 return name; 25 } 26 27 public String getIdentity() { 28 return identity; 29 } 30 31 public void setId(String id) { 32 this.id = id; 33 } 34 35 public void setName(String name) { 36 this.name = name; 37 } 38 39 public void setIdentity(String identity) { 40 this.identity = identity; 41 } 42} 43 2.使用 lombok 的方案 1 2@Data 3@Log4j 4@NoArgsConstructor 5@AllArgsConstructor 6public class Person { 7 8 private String id; 9 private String name; 10 private String identity; 11 12} 13
lombok 简化java代码注解 理解,布布扣,bubuko.com
标签:style http java color 使用 os
原文地址:http://my.oschina.net/baishi/blog/293785