Idea 模板创建Builder内部类

参考:https://www.cnblogs.com/happyflyingpig/p/9071316.html

自定义模板

public static class Builder {

	private ${class0.name} instance = new ${class0.name}();

	private Builder() {}

	#if ( $members.size() > 0 )
		#foreach( $member in $members )
		public Builder ${member.accessor}(${member.type} ${member.accessor}) {
			this.instance.${member.accessor} = ${member.accessor};
			return this;
		}
		#end
	#end

	public ${class0.name} build() {
		return this.instance;
	}
}

public static Builder builder() {
	return new Builder();
}

  

posted @ 2021-01-20 17:14  BINGJJFLY  阅读(464)  评论(0编辑  收藏  举报