plusone-commons API 修改
This commit is contained in:
parent
b7751512ff
commit
a135292909
@ -20,7 +20,7 @@ import com.google.common.annotations.Beta;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import xyz.zhouxy.plusone.commons.collection.AbstractMapWrapper;
|
import xyz.zhouxy.plusone.commons.collection.AbstractMapWrapper;
|
||||||
import xyz.zhouxy.plusone.commons.util.OptionalUtil;
|
import xyz.zhouxy.plusone.commons.util.OptionalTools;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -52,15 +52,15 @@ public class DbRecord extends AbstractMapWrapper<String, Object, DbRecord> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OptionalInt getValueAsInt(String key) {
|
public OptionalInt getValueAsInt(String key) {
|
||||||
return OptionalUtil.toOptionalInt(this.getAndConvert(key));
|
return OptionalTools.toOptionalInt(this.getAndConvert(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public OptionalLong getValueAsLong(String key) {
|
public OptionalLong getValueAsLong(String key) {
|
||||||
return OptionalUtil.toOptionalLong(this.getAndConvert(key));
|
return OptionalTools.toOptionalLong(this.getAndConvert(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public OptionalDouble getValueAsDouble(String key) {
|
public OptionalDouble getValueAsDouble(String key) {
|
||||||
return OptionalUtil.toOptionalDouble(this.getAndConvert(key));
|
return OptionalTools.toOptionalDouble(this.getAndConvert(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,7 +44,7 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
import xyz.zhouxy.plusone.commons.collection.CollectionTools;
|
import xyz.zhouxy.plusone.commons.collection.CollectionTools;
|
||||||
import xyz.zhouxy.plusone.commons.util.ArrayTools;
|
import xyz.zhouxy.plusone.commons.util.ArrayTools;
|
||||||
import xyz.zhouxy.plusone.commons.util.OptionalUtil;
|
import xyz.zhouxy.plusone.commons.util.OptionalTools;
|
||||||
|
|
||||||
@Beta
|
@Beta
|
||||||
public class SimpleJdbcTemplate {
|
public class SimpleJdbcTemplate {
|
||||||
@ -154,17 +154,17 @@ public class SimpleJdbcTemplate {
|
|||||||
|
|
||||||
public OptionalInt queryToInt(String sql, Object... params) throws SQLException {
|
public OptionalInt queryToInt(String sql, Object... params) throws SQLException {
|
||||||
Optional<Integer> result = queryFirst(sql, params, (rs, rowNumber) -> rs.getInt(1));
|
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 {
|
public OptionalLong queryToLong(String sql, Object... params) throws SQLException {
|
||||||
Optional<Long> result = queryFirst(sql, params, (rs, rowNumber) -> rs.getLong(1));
|
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 {
|
public OptionalDouble queryToDouble(String sql, Object... params) throws SQLException {
|
||||||
Optional<Double> result = queryFirst(sql, params, (rs, rowNumber) -> rs.getDouble(1));
|
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 {
|
public Optional<BigDecimal> queryToBigDecimal(String sql, Object... params) throws SQLException {
|
||||||
@ -254,16 +254,16 @@ public class SimpleJdbcTemplate {
|
|||||||
return Arrays.stream(params)
|
return Arrays.stream(params)
|
||||||
.map(param -> {
|
.map(param -> {
|
||||||
if (param instanceof Optional) {
|
if (param instanceof Optional) {
|
||||||
return OptionalUtil.orElseNull((Optional<?>) param);
|
return OptionalTools.orElseNull((Optional<?>) param);
|
||||||
}
|
}
|
||||||
if (param instanceof OptionalInt) {
|
if (param instanceof OptionalInt) {
|
||||||
return OptionalUtil.toInteger(((OptionalInt) param));
|
return OptionalTools.toInteger(((OptionalInt) param));
|
||||||
}
|
}
|
||||||
if (param instanceof OptionalLong) {
|
if (param instanceof OptionalLong) {
|
||||||
return OptionalUtil.toLong(((OptionalLong) param));
|
return OptionalTools.toLong(((OptionalLong) param));
|
||||||
}
|
}
|
||||||
if (param instanceof OptionalDouble) {
|
if (param instanceof OptionalDouble) {
|
||||||
return OptionalUtil.toDouble(((OptionalDouble) param));
|
return OptionalTools.toDouble(((OptionalDouble) param));
|
||||||
}
|
}
|
||||||
return param;
|
return param;
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user