Monday 26 October 2009

BarCampLondon7: Project Lombok - the end of Java boilerplate?

Reinier Zwitserloot - @surial

Project Lombok is an extension to Java that allows you to write less boilerplate code by using annotations.

  • examples:
    • @Data to provide automatic getters and setters for private fields, equality and hashCode, and a constructor for final fields
    • @Cleanup to tidy up inputstreams when block ends
    • @Synchronized to lock on private Object instance rather than this
    • @SneakyThrows() hides a checked exception from javac, but leaves it for JVM
    • (in JVM all exceptions are unchecked)
  • integrates with Eclipse (e.g. getters/setters provided without you having to type)
  • does mucking around through its jar, so can work easily with Ant & Maven etc
    • use com.sun...ProcessingEnvironment to
  • Java Posse — podcast
    • inventor of annotations happy that lombok exists, but not so happy that private APIs being used…

No comments: