Lombok @Builder example
The @Builder annotation produces complex builder APIs for your classes.
public class BuilderExample {
private String name;
private int age;
BuilderExample(String name, int age) {
this.name = name;
this.age = age;
this.occupations = occupations;
}
//setter and getter
}
import lombok.Builder;
import lombok.Singular;
@Builder
public class BuilderExample {
private String name;
private int age;
}
Java With Out Lombok
public class BuilderExample {
private String name;
private int age;
BuilderExample(String name, int age) {
this.name = name;
this.age = age;
this.occupations = occupations;
}
//setter and getter
}
With Lombok
import lombok.Builder;
import lombok.Singular;
@Builder
public class BuilderExample {
private String name;
private int age;
}
Lombok with java 8 example
BuilderExample.builder().name("Test").age(20).build();
Comments
Post a Comment