public Builder setName(String name) { this.name = name; returnthis; }
public Builder setMaxTotal(Integer maxTotal) { this.maxTotal = maxTotal; returnthis; }
public Builder setMaxIdle(Integer maxIdle) { this.maxIdle = maxIdle; returnthis; }
public Builder setMinIdle(Integer minIdle) { this.minIdle = minIdle; returnthis; }
public ResourcePoolConfig2 build() { // 校验逻辑放到这里来做,包括必填项校验、依赖关系校验、约束条件校验等 if (null == name) { thrownewIllegalArgumentException("name should not be empty."); } if (maxTotal != null) { if (maxTotal <= 0) { thrownewIllegalArgumentException("maxTotal should be positive."); } } if (maxIdle != null) { if (maxIdle < 0) { thrownewIllegalArgumentException("maxIdle should not be negative."); } } if (minIdle != null) { if (minIdle < 0) { thrownewIllegalArgumentException("minIdle should not be negative."); } } if (maxIdle > maxTotal) { thrownewIllegalArgumentException("..."); } if (minIdle > maxTotal || minIdle > maxIdle) { thrownewIllegalArgumentException("..."); }