Post Referenced: https://keaplogik.blogspot.com/2013/04/java-developers-need-to-be-using-lombok.html
This particular post is in reference to the java library Project Lombok, and can be downloaded here https://projectlombok.org/download completely free. The tool can also be supported by donations and directly through their patreon page https://www.patreon.com/lombok.
Billy Yarosh describes Lombok as “a java library meant to simplify the development of Java code writing. He then goes on to show an example of the library in use:
public class Animal {
private String name;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
With the use of the Lombak library you can turn all of that code into something much smaller:
public class Animal {
@Getter @Setter private String name;
}
I was impressed at the simplicity that this library would bring to the java language. As I always thought that Java was a bulky code that had a lot of writing involved. Especially since learning C I think about how overly complicated Java can be. The question that I raise is: does a library like this promote laziness, or does the good outweigh the bad? Personally I think a library like this is the perfect thing to have in your coding “arsenal” because it would save you valuable time to achieve the same result. However I do think that it would be important to still learn the original Java created form first, and master that understanding before using the library. Lombak should be used as a shortcut to pass monotonous material that adds up, and not to just do something easier.
Other advantages that Billy lists are as follows: “
- No more overriding toString
- We can now annotate our class with a @ToString and lombok will override our toString method and print out the classes fields.
- No more overriding equals and hashCode methods.
- Annotate class with @EqualsAndHashCode for easy generation of equals and hashCode methods at compile time.
- Generates constructors based on class annotations.
- @NoArgsConstructor used for creating a no argument constructor.
- @RequiredArgsConstructor used for creating constructor that takes one argument per non final/ non-null fields.
- @AllArgsConstructor used for creating constructor takes in one argument for every field.
- Use @Data shortcut for @ToString, @EqualsAndHashCode, @ RequiredArgsConstructor, and @Getter / @Setter (on all non final fields). ”
Learning of a tool like Lombak has me thinking of the other libraries that may be out there to help save programmers time, and plan to look into them more in the future. Have you had any experience with Lombak, or other libraries? What were your thoughts on them?
-ComputingFinn (CS 343)
From the blog CS@Worcester – Computing Finn by computingfinn and used with permission of the author. All other rights reserved by the author.