середа, 9 січня 2013 р.

Lombok project

If you tired of writing get/set or equals/hashcode methods you can try Lombok. It's a cute project which provides several useful annotations  like

@Getter / @Setter
Never write public int getFoo() {return foo;} again.
Laziness is a virtue!
No need to start a debugger to see your fields: Just let lombok generate a toString for you!
Generates hashCode and equals implementations from the fields of your object.

and many others.

With Lombok your class will look like
01 import lombok.ToString;
03 @ToString(exclude="id")
04 public class ToStringExample {
05   private static final int STATIC_VAR = 10;
06   @Getter @Setter(AccessLevel.PROTECTED) private String name;
07   @Getter @Setter  private int id;
09 }