MAC Eclipse Installation Lombok

Source: Internet
Author: User

Lombok is a tool that can be used in the form of annotations to help eliminate some of the necessary but bloated Java code, by using the corresponding annotations, you can generate the corresponding method when compiling the source code, such as the class attribute of the Get/set/tostring ()/class construction method.

  

Below is a note on how Mac Eclipse installs Lombok

1, download the corresponding jar package Lombok.jar,:https://projectlombok.org/download

2. Integrate Lombok into eclipse

(1) Lombok copy to the Eclipse.app/contents/eclipse directory;

      

(2) Add the following content to the Eclipse.ini tail

-javaagent:.. /eclipse/lombok.jar-vmargs-javaagent:lombok.jar

3. Restart Eclipse.

The following notes are commonly used

  1. Introduction of Lombok jar in MAVEN project

<!--Https://mvnrepository.com/artifact/org.projectlombok/lombok -<Dependency>    <groupId>Org.projectlombok</groupId>    <Artifactid>Lombok</Artifactid>    <version>1.16.20</version>    <Scope>Provided</Scope></Dependency>

  2. Use annotations

@Data  Public class User {        privateint  ID;         Private String userName;         Private Date birthday;}

  
@Setter and @Getter

Annotations provide the setting method for a property on a property (or, of course, on a class), and the default generated method is public, and you can set Accesslever if you want to modify it. As follows

 Public class User {        privateint  ID;         Private String userName;         Private Date birthday;}

@ToString

Annotations on the class, generate the ToString () method, which, by default, prints your class name and each field in order (comma delimited). This can be set to not contain which fields @tostring (exclude= "id"), if there is more than @tostring (exclude={"id", "name"}), if there is inheritance of the parent class, you can have it call the parent class ToString (), such as @tostring (Calllsuper = True)     

@ToString (exclude = "id")publicclass  User {        privateint ID;         Private String userName;         Private Date birthday;}  

@NoArgsConstructor, @RequiredArgsConstructor, @AllArgsConstructor

@NoArgsConstructor generates an parameterless construction method. When there is a final field in the class that is not initialized, the compiler will error, @noargsconstructor (force = True) is available, and then the default value 0/false/null will be set for the final field without initialization.  For fields with constraints, such as the @nonnull field, no checks or allocations are generated, so be aware that these constraints are not valid until these fields are properly initialized. @RequiredArgsConstructor generates a construction method (possibly with or without parameters), if with parameters, this parameter can only be a final decorated uninitialized field, or an uninitialized field with @nonnull annotations
@RequiredArgsConstructor (Staticname = "of") generates a static method of () and sets the construction method to private @AllArgsConstructor generates a full-parameter construction method @Data simultaneously generates @   Getter @Setter functions such as @ToString @RequiredArgsConstructor. @Synchronized Add a sync lock to a method Synchronized more about the official documentation Https://projectlombok.org/features/all


MAC Eclipse Installation Lombok

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.