增加重载GenericBuilder的of接口,支持有参构造(最多5个)的调用;增加重载with接口,支持无参方法调用

This commit is contained in:
TomXin
2022-01-30 14:06:43 +08:00
parent 9d5c2ffc1a
commit c0d2b8c9e3
2 changed files with 262 additions and 18 deletions

View File

@@ -1,8 +1,7 @@
package cn.hutool.core.builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import cn.hutool.core.util.StrUtil;
import lombok.*;
import org.junit.Test;
/**
@@ -31,6 +30,11 @@ public class GenericBuilderTest {
.with(Box::setHeight, 5)
.build();
System.out.println(boxModified);
Box box1 = GenericBuilder
.of(Box::new, 2048L, "Hello Partner!", 222, 333, 444)
.with(Box::alis)
.build();
System.out.println(box1);
}
@Getter
@@ -42,6 +46,24 @@ public class GenericBuilderTest {
private Integer length;
private Integer width;
private Integer height;
private String titleAlias;
public Box() {
}
public Box(Long id, String title, Integer length, Integer width, Integer height) {
this.id = id;
this.title = title;
this.length = length;
this.width = width;
this.height = height;
}
public void alis() {
if (StrUtil.isNotBlank(this.title)) {
this.titleAlias = "TomXin:\"" + title + "\"";
}
}
}
}