Project Lombok!
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Project Lombok!

  • 1,240 views
Uploaded 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......

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.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,240
On Slideshare
1,239
From Embeds
1
Number of Embeds
1

Actions

Shares
Downloads
9
Comments
0
Likes
1

Embeds 1

http://instacurate.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    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.

Transcript

  • 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. Demo Video Taken from http://projectlombok.org/ Gives an idea what Project Lombok is and how it can be installed. Simple Demo of few Features.
  • 3. Features@Getter, @Setter, @ToString, @EqualsAndHashCode, @Data@NoArgsConstructor, @RequiredArgsConstructor and@AllArgsConstructor@Cleanup, @Synchronized@Log@Delegateval
  • 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. @ToStringGenerates a default implementation of the toString()methodParameters Demo
  • 6. @EqualsAndHashCodeGenerates hashCode and equals implementations fromthe fields (non-static, non-transient)Parameters Demo
  • 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. @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. @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. Logger Annotations!Generate a logger field with name “log”Four options @CommonsLog @Log @Log4j @Slf4j
  • 11. And Lot More!!!Some other supported features like@Delegate, @Synchronized, val etc.More to come soon!Open SourceDetails can be found at http://projectlombok.org/