Project Lombok!


Published on

The introduction of Project Lombok, a combination compile-time and development-time code generator, has made Java POJO verbosity history. Add Lombok to your daily coding practices, and you won't go back.

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • @Getter / @SetterNever write public intgetFoo() {return foo;} again.@ToStringNo need to start a debugger to see your fields: Just let lombok generate a toString for you!@EqualsAndHashCodeEquality made easy: Generates hashCode and equals implementations from the fields of your object.@DataAll together now: A shortcut for @ToString, @EqualsAndHashCode, @Getter on all fields, and @Setter on all non-final fields, and @RequiredArgsConstructor!@NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructorConstructors made to order: Generates constructors that take no arguments, one argument per final / non-null field, or one argument for every field.@CleanupAutomatic resource management: Call your close() methods safely with no hassle.@Synchronizedsynchronized done right: Don't expose your locks.@LogCaptain's Log, stardate 24435.7: "What was that line again?"@DelegateDon't lose your composition.valFinally! Hassle-free final local variables.
  • Project Lombok!

    1. 1. Problems of the Industry Boiler Plate Code Syntax Verbosity Non Standardization Not following the standard code conventions!! Human Error/Dependency Repeatable things (defining Getters, Setters etc.)
    2. 2. Demo Video Taken from Gives an idea what Project Lombok is and how it can be installed. Simple Demo of few Features.
    3. 3. Features@Getter, @Setter, @ToString, @EqualsAndHashCode, @Data@NoArgsConstructor, @RequiredArgsConstructor and@AllArgsConstructor@Cleanup, @Synchronized@Log@Delegateval
    4. 4. @Getter and @Setter Automatic Generation of getters and setters. Method will be public unless you explicitly specify an AccessLevel @Getter and/or @Setter annotation on class Disable getter/setter generation for any field by using the special AccessLevel.NONE @NotNull for nullity check Demo
    5. 5. @ToStringGenerates a default implementation of the toString()methodParameters Demo
    6. 6. @EqualsAndHashCodeGenerates hashCode and equals implementations fromthe fields (non-static, non-transient)Parameters Demo
    7. 7. Constructor level Annotations@NoArgsConstructor, @RequiredArgsConstructor, @AllArgsConstructorGenerates constructors that take no arguments, oneargument per final / non-null field, or one argument forevery field.Specialized constructor can be made. Compile-time errorin case of any conflicts.Demo
    8. 8. @DataAll together now: A shortcut for@ToString, @EqualsAndHashCode, @Getter on allfields, @Setter on all non-final fields, and@RequiredArgsConstructorIncluded annotations with changed parameters can bedefined along with @Data
    9. 9. @CleanupAutomatic resource management: Call your close() methodssafely with no hassle.Example: @Cleanup InputStream in = newFileInputStream("some/file");If the type of object youd like to cleanup does not have aclose() method, but some other no-argument method likedispose() so write it as@Cleanup("dispose") TestClass t = new TestClass();
    10. 10. Logger Annotations!Generate a logger field with name “log”Four options @CommonsLog @Log @Log4j @Slf4j
    11. 11. And Lot More!!!Some other supported features like@Delegate, @Synchronized, val etc.More to come soon!Open SourceDetails can be found at
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.