plusone-commons API 修改

This commit is contained in:
zhouxy108 2024-06-17 09:22:06 +08:00
parent b7751512ff
commit a135292909
2 changed files with 12 additions and 12 deletions

View File

@ -20,7 +20,7 @@ import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import xyz.zhouxy.plusone.commons.collection.AbstractMapWrapper;
import xyz.zhouxy.plusone.commons.util.OptionalUtil;
import xyz.zhouxy.plusone.commons.util.OptionalTools;
import java.util.*;
@ -52,15 +52,15 @@ public class DbRecord extends AbstractMapWrapper<String, Object, DbRecord> {
}
public OptionalInt getValueAsInt(String key) {
return OptionalUtil.toOptionalInt(this.getAndConvert(key));
return OptionalTools.toOptionalInt(this.getAndConvert(key));
}
public OptionalLong getValueAsLong(String key) {
return OptionalUtil.toOptionalLong(this.getAndConvert(key));
return OptionalTools.toOptionalLong(this.getAndConvert(key));
}
public OptionalDouble getValueAsDouble(String key) {
return OptionalUtil.toOptionalDouble(this.getAndConvert(key));
return OptionalTools.toOptionalDouble(this.getAndConvert(key));
}
@Override

View File

@ -44,7 +44,7 @@ import com.google.common.collect.Lists;
import xyz.zhouxy.plusone.commons.collection.CollectionTools;
import xyz.zhouxy.plusone.commons.util.ArrayTools;
import xyz.zhouxy.plusone.commons.util.OptionalUtil;
import xyz.zhouxy.plusone.commons.util.OptionalTools;
@Beta
public class SimpleJdbcTemplate {
@ -154,17 +154,17 @@ public class SimpleJdbcTemplate {
public OptionalInt queryToInt(String sql, Object... params) throws SQLException {
Optional<Integer> result = queryFirst(sql, params, (rs, rowNumber) -> rs.getInt(1));
return OptionalUtil.toOptionalInt(result);
return OptionalTools.toOptionalInt(result);
}
public OptionalLong queryToLong(String sql, Object... params) throws SQLException {
Optional<Long> result = queryFirst(sql, params, (rs, rowNumber) -> rs.getLong(1));
return OptionalUtil.toOptionalLong(result);
return OptionalTools.toOptionalLong(result);
}
public OptionalDouble queryToDouble(String sql, Object... params) throws SQLException {
Optional<Double> result = queryFirst(sql, params, (rs, rowNumber) -> rs.getDouble(1));
return OptionalUtil.toOptionalDouble(result);
return OptionalTools.toOptionalDouble(result);
}
public Optional<BigDecimal> queryToBigDecimal(String sql, Object... params) throws SQLException {
@ -254,16 +254,16 @@ public class SimpleJdbcTemplate {
return Arrays.stream(params)
.map(param -> {
if (param instanceof Optional) {
return OptionalUtil.orElseNull((Optional<?>) param);
return OptionalTools.orElseNull((Optional<?>) param);
}
if (param instanceof OptionalInt) {
return OptionalUtil.toInteger(((OptionalInt) param));
return OptionalTools.toInteger(((OptionalInt) param));
}
if (param instanceof OptionalLong) {
return OptionalUtil.toLong(((OptionalLong) param));
return OptionalTools.toLong(((OptionalLong) param));
}
if (param instanceof OptionalDouble) {
return OptionalUtil.toDouble(((OptionalDouble) param));
return OptionalTools.toDouble(((OptionalDouble) param));
}
return param;
})