One of the drawback of Java language is its verbosity. One very easy example can be found in any typical Java POJO.
public class Order{
private long id;
private String name;
private int size;
public Order(){
}
public Order(long id){
this.id = id;
}
public long getId(){
return id;
}
public void setId(long id){
this.id = id;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public int getSize(){
return size();
}
public void setSize(int size){
this.size = size;
}
@Override
public String toString(){
return String.format("%s %d %d", id, name, size);
}
}
Already that much code just for a very simple structure with constructors, getters, setters, and toString method. This is where Lombok comes to save the day! Instead of writing that much code, you can have something like this:@Data
public class Order{
private long id;
private String name;
private int size;
}
...and that's it! A clean, nice code that is easy to maintain. The @Data annotation will tell Lombok to generate the constructor, getters and setters, toString method (and even equals and hashCode method!) all during compilation time! (instead of hiding the code in other file ala AspectJ). Since Lombok can be integrated with your IDE, you will not lose the nice content assist or any other feature that you currently enjoying.There are several other features provided by Lombok (see: Lombok features), although personally for me, this one is going to be the one I use the most. I am not too scared of introducing Lombok dependency to my project since Lombok itself presented a nice way to stop using Lombok dependency with a tool called "delombok". By using delombok, all magically generated code will be written to the source code and the dependency to Lombok library will be removed.
The only drawback I can think of is whenever I rename one of the field name and the rest of code which refer to the getter/setter will also need to be updated manually (instead of having them automatically updated using a refactor tool in your IDE), but it is a very small price to pay (I guess).
Agree. Lombok is cool. Why it is not a plugin for Eclipse???? :(
ReplyDeleteI could not refrain from commenting. Well written!
ReplyDeleteHere is my web-site: White Kidney Bean Diet
Thank you for the good writeup. It in fact was a amusement account it.
ReplyDeleteLook advanced to far added agreeable from you! However, how could we
communicate?
my page :: the ketone is discovered similarly very easily. Thermogenesis is the process of accelerating the genuine temp of the corporel. Even though I am certain need to you took a hundred tablets at a time you may well expertise some! Raspberry ketone is an phenol
What's up to every single one, it's really a
ReplyDeletenice for me to pay a visit this site, it contains helpful Information.
Feel free to surf to my web site; bawash.com
Thank you for the auspicious writeup. It actually was once a amusement account it.
ReplyDeleteGlance complicated to more brought agreeable from you!
However, how could we keep in touch?
Here is my webpage :: Recycling facts
Hey there! I just wanted to ask if you ever have
ReplyDeleteany issues with hackers? My last blog (wordpress) was hacked and I ended up losing several weeks of hard work
due to no back up. Do you have any methods to stop hackers?
Feel free to visit my web page :: Permanent hair straightening
Thank you for the auspicious writeup. It in fact was a amusement account it.
ReplyDeleteLook advanced to far added agreeable from you! By the way, how can we
communicate?
Also visit my web site; Diarrhea Remedies
Thank you for sharing such kind of information. Your information is always useful for me, keep it up and you are subscribed.
ReplyDelete__________
Buy Online LTO6 Tape
That is very fascinating, You're an excessively skilled blogger. I've joined your
ReplyDeletefeed and sit up for in quest of extra of your wonderful post.
Additionally, I've shared your web site in my social networks
Feel free to surf to my web page - review
Hey! Do you use Twitter? I'd like to follow you if that would be okay. I'm undoubtedly enjoying your blog and look forward to new posts.
ReplyDeleteFeel free to visit my website: http://greencoffeediets.org/
Wow! This blog looks just like my old one! It's on a completely different topic but it has pretty much the same page layout and design. Outstanding choice of colors!
ReplyDeleteAlso visit my web site: Library Relocation
Just desire to say your article is as surprising. The
ReplyDeleteclarity in your post is simply spectacular and
i can assume you're an expert on this subject. Well with your permission allow me to grab your feed to keep updated with forthcoming post. Thanks a million and please keep up the rewarding work.
my web-site ... Raspberry ketone Plus Reviews
This blog was... how do you say it? Relevant!! Finally I've found something which helped me. Thank you!
ReplyDeleteAlso visit my web site - Test Force Muscle Testosterone Booster
Article writing is also a excitement, if you know then you can write otherwise it is complicated to write.
ReplyDeleteTake a look at my blog post ... Beta Force And Max Thermo Burn
Wow that was odd. I just wrote an extremely long comment but
ReplyDeleteafter I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that
over again. Anyhow, just wanted to say great blog!
my website; Instant Payday Loans Online
Hi it's me, I am also visiting this site on a regular basis, this site is truly nice and the users are truly sharing nice thoughts.
ReplyDeleteHere is my blog ... Muscle X
Everyone loves what you guys tend to be up too. This kind of clever work and exposure!
ReplyDeleteKeep up the fantastic works guys I've added you guys to my blogroll.
Feel free to surf to my web blog - Veluminous Skin Care