Commit f5862372 authored by James's avatar James
Browse files

eache 方法修改 Function 泛型

Showing with 17 additions and 9 deletions
+17 -9
......@@ -72,7 +72,7 @@ public class DaoTemplate<M extends Model> {
// ---------
public void each(Function<Model, Boolean> func) {
public void each(Function<M, Boolean> func) {
dao.each(func, sqlPara.getSql(), sqlPara.getPara());
}
......
......@@ -1104,7 +1104,7 @@ public abstract class Model<M extends Model> implements Serializable {
* }, sql, paras);
* </pre>
*/
public void each(Function<Model, Boolean> func, String sql, Object... paras) {
public void each(Function<M, Boolean> func, String sql, Object... paras) {
Config config = _getConfig();
Connection conn = null;
try {
......
......@@ -43,7 +43,7 @@ public class ModelBuilder {
}
@SuppressWarnings({"rawtypes", "unchecked"})
public <T> List<T> build(ResultSet rs, Class<? extends Model> modelClass, Function<Model, Boolean> func) throws SQLException, ReflectiveOperationException {
public <T> List<T> build(ResultSet rs, Class<? extends Model> modelClass, Function<T, Boolean> func) throws SQLException, ReflectiveOperationException {
List<T> result = new ArrayList<T>();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
......@@ -75,7 +75,7 @@ public class ModelBuilder {
if (func == null) {
result.add((T)ar);
} else {
if ( ! func.apply(ar) ) {
if ( ! func.apply((T)ar) ) {
break ;
}
}
......
......@@ -42,13 +42,15 @@ public class KeepByteAndShortModelBuilder extends ModelBuilder {
public static final KeepByteAndShortModelBuilder me = new KeepByteAndShortModelBuilder();
@Override
@SuppressWarnings({"rawtypes"})
public <T> List<T> build(ResultSet rs, Class<? extends Model> modelClass) throws SQLException, ReflectiveOperationException {
return build(rs, modelClass, null);
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public <T> List<T> build(ResultSet rs, Class<? extends Model> modelClass, Function<Model, Boolean> func) throws SQLException, ReflectiveOperationException {
public <T> List<T> build(ResultSet rs, Class<? extends Model> modelClass, Function<T, Boolean> func) throws SQLException, ReflectiveOperationException {
List<T> result = new ArrayList<T>();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
......@@ -91,7 +93,7 @@ public class KeepByteAndShortModelBuilder extends ModelBuilder {
if (func == null) {
result.add((T)ar);
} else {
if ( ! func.apply(ar) ) {
if ( ! func.apply((T)ar) ) {
break ;
}
}
......
......@@ -44,10 +44,12 @@ public class KeepByteAndShortRecordBuilder extends RecordBuilder {
public static final KeepByteAndShortRecordBuilder me = new KeepByteAndShortRecordBuilder();
@Override
public List<Record> build(Config config, ResultSet rs) throws SQLException {
return build(config, rs, null);
}
@Override
@SuppressWarnings("unchecked")
public List<Record> build(Config config, ResultSet rs, Function<Record, Boolean> func) throws SQLException {
List<Record> result = new ArrayList<Record>();
......
......@@ -37,13 +37,15 @@ public class TimestampProcessedModelBuilder extends ModelBuilder {
public static final TimestampProcessedModelBuilder me = new TimestampProcessedModelBuilder();
@Override
@SuppressWarnings({"rawtypes"})
public <T> List<T> build(ResultSet rs, Class<? extends Model> modelClass) throws SQLException, ReflectiveOperationException {
return build(rs, modelClass, null);
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public <T> List<T> build(ResultSet rs, Class<? extends Model> modelClass, Function<Model, Boolean> func) throws SQLException, ReflectiveOperationException {
public <T> List<T> build(ResultSet rs, Class<? extends Model> modelClass, Function<T, Boolean> func) throws SQLException, ReflectiveOperationException {
List<T> result = new ArrayList<T>();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
......@@ -79,7 +81,7 @@ public class TimestampProcessedModelBuilder extends ModelBuilder {
if (func == null) {
result.add((T)ar);
} else {
if ( ! func.apply(ar) ) {
if ( ! func.apply((T)ar) ) {
break ;
}
}
......
......@@ -39,10 +39,12 @@ public class TimestampProcessedRecordBuilder extends RecordBuilder {
public static final TimestampProcessedRecordBuilder me = new TimestampProcessedRecordBuilder();
@Override
public List<Record> build(Config config, ResultSet rs) throws SQLException {
return build(config, rs, null);
}
@Override
@SuppressWarnings("unchecked")
public List<Record> build(Config config, ResultSet rs, Function<Record, Boolean> func) throws SQLException {
List<Record> result = new ArrayList<Record>();
......
......@@ -136,7 +136,7 @@ public abstract class Dialect {
}
@SuppressWarnings("rawtypes")
public void eachModel(ResultSet rs, Class<? extends Model> modelClass, Function<Model, Boolean> func) throws SQLException, ReflectiveOperationException {
public <T> void eachModel(ResultSet rs, Class<? extends Model> modelClass, Function<T, Boolean> func) throws SQLException, ReflectiveOperationException {
modelBuilder.build(rs, modelClass, func);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment