Knowing this plug-in can save 1000 lines of code in your project

In project development, we often encounter the need to create entity classes. The general approach is to write member variables first, then provide methods corresponding to get and set, and then see whether toString and other methods need to be provided. In this way, it will be found that every time an entity class is written, there will be many similar operations, and the amount of code seems to be a lot, which is not very concise. Of course, these entity classes can also be generated with the help of tools or in the form of annotations directly. There are only member variables and no get and set related methods. The main idea is that Lombok is a Java library that can automatically insert editors and build tools to simplify java development. By adding annotations, there is no need to write getter or requests methods for the class, and the log variables can be automated. The annotation < / P > < p > actually provides get, set, equals, hashcode, toString methods for our class. In other words, as long as you write this annotation on your class, you don’t need to generate get, set, toString and other methods. It’s similar to that when we do Android development, we see a lot of tedious code of findviewbyid. We use the butterknife plug-in. < / P > < p > @ setter annotation generates setter method for all fields when annotation is in class or field, and only setter method is generated for this field when annotation is on field. < / P > < p > Second, although it saves the trouble of manually creating getter / setter methods, it greatly reduces the readability and integrity of source code, and reduces the comfort of reading source code. < / P > < p > for the second point, I don’t quite agree. The set and get readability of entity classes are not very important. Who will pay attention to these? Video Number assistant internal test online! Four functions let you send 1g video on the computer

Author: zmhuaxia