标签:pac pil user 传参 com file oid 参与 ack
package com.yang.webflux.controller;
import lombok.Builder;
/**
* @author: Yang
* @date: 2017/3/26 23:55
* @description:
*/
@Builder
public class User {
private long id;
private String name;
private int age;
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.yang.webflux.controller;
public class User {
private long id;
private String name;
private int age;
User(long id, String name, int age) {
this.id = id;
this.name = name;
this.age = age;
}
public static User.UserBuilder builder() {
return new User.UserBuilder();
}
public static class UserBuilder {
private long id;
private String name;
private int age;
UserBuilder() {
}
public User.UserBuilder id(long id) {
this.id = id;
return this;
}
public User.UserBuilder name(String name) {
this.name = name;
return this;
}
public User.UserBuilder age(int age) {
this.age = age;
return this;
}
public User build() {
return new User(this.id, this.name, this.age);
}
public String toString() {
return "User.UserBuilder(id=" + this.id + ", name=" + this.name + ", age=" + this.age + ")";
}
}
}
public static void main(String[] args) {
User user = User.builder()
.id(1L)
.name("yang")
.age(3)
.build();
}
package com.yang.webflux.controller;
import lombok.Data;
/**
* @author: Yang
* @date: 2017/3/26 23:41
* @description:
*/
public class MyDsl {
public static void main(String[] args) {
Dog yang = Dog.builder().age(1).id(3L).name("yang").build();
System.out.println(yang.getAge());
System.out.println(yang.getId());
System.out.println(yang.getName());
}
}
@Data
class Dog {
private long id;
private String name;
private int age;
/**
* 此构造函数的传参与lombok的有所不同
*/
private Dog(Builder builder) {
this.id = builder.id;
this.name = builder.name;
this.age = builder.age;
}
public static Builder builder() {
return new Dog.Builder();
}
public static final class Builder {
private long id;
private String name;
private int age;
public Builder() {
}
public Builder id(long id) {
this.id = id;
return this;
}
public Builder name(String name) {
this.name = name;
return this;
}
public Builder age(int age) {
this.age = age;
return this;
}
public Dog build() {
return new Dog(this);
}
}
}
标签:pac pil user 传参 com file oid 参与 ack
原文地址:https://www.cnblogs.com/JaxYoun/p/14891725.html