In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article to share with you is about Java development is available Lombok, Xiaobian feel quite practical, so share to everyone to learn, I hope you can read this article after some harvest, not much to say, follow Xiaobian to see it.
Should Java developers use Lombok?
Lombok Profile
Lombok is not a new project. On the contrary, it has a long history, but the controversy about Lombok has never stopped. Let's first see what it is.
According to Lombok's official website:
Lombok is a java library that automatically inserts editors and build tools, adds color to our java, lets developers say goodbye to complicated getter/setter and equals methods, and a comment can make our class have a fully functional builder.
At first glance, it's still quite tempting. I believe everyone has been tired of doing Java development for the boilerplate code getter/setter. Although you can use development tools to generate it automatically, it's still a bit annoying to see that a lot of code. See someone recommend Kotlin. Kotlin for Android is OK. Instead of Java for enterprise applications? hehe. Lombok can help developers simplify boilerplate code. For a simple example, your Java Bean might look like this:
public class User{ private String name; private Long id; private String address; //getter/setter/toString/hashCode。。。}
With Lombok, your Java Bean can be simplified to look like this:
@Datapublic class User{ private String name; private Long id; private String address;}
Add a @Data annotation, the project in the compiler compilation through the operation AST (abstract syntax tree) to automatically generate getters/setter, toString, hashCode and other methods, using this feature, even like JavaScript without explicit declaration of variable types:
val list = new ArrayList();list.add(new User());
Such code will eventually be compiled into:
final ArrayList list = new ArrayList();list.add(new User());
There are many other syntax sugar, such as @Cleanup,@Builder, etc. are all experts in simplifying code, I am just giving two random examples here.
Because these codes are compiled only after, so developers need to call an object's get method (or other automatically generated methods) in Java code, but also need to introduce some development tools plug-in, can solve this problem, I won't go into detail, everyone interested can search for it.
Things are such a thing, tools are such a tool, so in the end do you use it in development?
The above is whether Lombok is available in Java development. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.