Android, Java, Long, Overview, Utils

Project Lombok – first look

Project Lombok allows reducing the unnecessary code. By annotations generates getters, setters, constructors, toString, hash or others. Spice up your Java!

How to add to project?

  1. apt org.projectlombok:lombok:1.16.12
    compile “org.projectlombok:lombok:1.16.12”
    add to section dependencies in gradle
  2. Install plugin “Lombok Plugin”

– @NonNull


Vanilla Java:

– @Getter/@Setter


Vanilla Java:


  • – generated names in this way: foo -> getFoo()
  • – default access is  public
  • @Getter/@Setter can be used relative to the entire class, then they concern all non-static data
  • – if you want turn off generating setter or getter you can get it throught  AccessLevel.NONE

– @ToString


Vanilla Java:


  • default class name with fields
  • exlude field through exclude e.g exclude="id"
  • add name fileds through includeFieldNames=true  
  • add method toString from super through callSuper=true


– @CleanUp

– @EqualAndHashCode

– @NoArgsConstructor, @RequiredArgsConstructor, @AllArgsConstructor

– @Data

– @Value

– @Builder

– @SneakyThrows

– @Synchronized

– @Getter(lazy=true)

– @Log



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s