This commit is contained in:
Looly
2022-05-07 13:24:02 +08:00
parent 029a603d5f
commit 36d75d7030
81 changed files with 525 additions and 494 deletions

View File

@@ -554,7 +554,7 @@ public abstract class AbstractDb<R extends AbstractDb<R>> extends DefaultConnect
* @throws DbRuntimeException SQL执行异常
*/
public <T> T find(final Entity where, final RsHandler<T> rsh, final String... fields) throws DbRuntimeException {
return find(ListUtil.toList(fields), where, rsh);
return find(ListUtil.of(fields), where, rsh);
}
/**

View File

@@ -156,7 +156,7 @@ public class Entity extends Dict {
*/
public Entity setFieldNames(final Collection<String> fieldNames) {
if (CollUtil.isNotEmpty(fieldNames)) {
this.fieldNames = SetUtil.newHashSet(true, fieldNames);
this.fieldNames = SetUtil.of(true, fieldNames);
}
return this;
}
@@ -169,7 +169,7 @@ public class Entity extends Dict {
*/
public Entity setFieldNames(final String... fieldNames) {
if (ArrayUtil.isNotEmpty(fieldNames)) {
this.fieldNames = SetUtil.newLinkedHashSet(fieldNames);
this.fieldNames = SetUtil.ofLinked(fieldNames);
}
return this;
}

View File

@@ -134,7 +134,7 @@ public interface Dialect extends Serializable {
* @throws SQLException SQL执行异常
*/
default PreparedStatement psForCount(final Connection conn, final Query query) throws SQLException {
return psForFind(conn, query.clone().setFields(ListUtil.toList("count(1)")));
return psForFind(conn, query.clone().setFields(ListUtil.of("count(1)")));
}
/**

View File

@@ -272,7 +272,7 @@ public class MetaUtil {
indexInfo.getColumnIndexInfoList().add(ColumnIndexInfo.create(rs));
}
}
table.setIndexInfoList(ListUtil.toList(indexInfoMap.values()));
table.setIndexInfoList(ListUtil.of(indexInfoMap.values()));
}
} catch (final SQLException e) {
throw new DbRuntimeException("Get columns error!", e);

View File

@@ -55,7 +55,7 @@ public class ConditionBuilder implements Builder<String> {
* @return 参数列表
*/
public List<Object> getParamValues() {
return ListUtil.unmodifiable(this.paramValues);
return ListUtil.view(this.paramValues);
}
/**

View File

@@ -113,7 +113,7 @@ public class Query implements Cloneable {
* @return this
*/
public Query setFields(final String... fields) {
this.fields = ListUtil.toList(fields);
this.fields = ListUtil.of(fields);
return this;
}

View File

@@ -107,7 +107,7 @@ public class CRUDTest {
@Test
public void findTest() {
final List<Entity> find = db.find(ListUtil.toList("name AS name2"), Entity.create("user"), new EntityListHandler());
final List<Entity> find = db.find(ListUtil.of("name AS name2"), Entity.create("user"), new EntityListHandler());
Assert.assertFalse(find.isEmpty());
}
@@ -168,7 +168,7 @@ public class CRUDTest {
Console.log(data1);
Console.log(data2);
final int[] result = db.insert(ListUtil.toList(data1, data2));
final int[] result = db.insert(ListUtil.of(data1, data2));
Console.log(result);
}
@@ -185,7 +185,7 @@ public class CRUDTest {
Console.log(data1);
final int[] result = db.insert(ListUtil.toList(data1));
final int[] result = db.insert(ListUtil.of(data1));
Console.log(result);
}

View File

@@ -31,7 +31,7 @@ public class ConcurentTest {
for(int i = 0; i < 10000; i++) {
ThreadUtil.execute(() -> {
final List<Entity> find;
find = db.find(ListUtil.toList("name AS name2"), Entity.create("user"), new EntityListHandler());
find = db.find(ListUtil.of("name AS name2"), Entity.create("user"), new EntityListHandler());
Console.log(find);
});
}

View File

@@ -15,7 +15,7 @@ public class PicTransferTest {
@Ignore
public void findTest() {
Db.of().find(
ListUtil.of("NAME", "TYPE", "GROUP", "PIC"),
ListUtil.view("NAME", "TYPE", "GROUP", "PIC"),
Entity.create("PIC_INFO").set("TYPE", 1),
rs -> {
while(rs.next()){

View File

@@ -27,7 +27,7 @@ public class MetaUtilTest {
@Test
public void getTableMetaTest() {
final Table table = MetaUtil.getTableMeta(ds, "user");
Assert.assertEquals(SetUtil.newHashSet("id"), table.getPkNames());
Assert.assertEquals(SetUtil.of("id"), table.getPkNames());
}
@Test

View File

@@ -23,6 +23,6 @@ public class ConditionGroupTest {
final ConditionBuilder conditionBuilder = ConditionBuilder.of(cg2, condition4);
Assert.assertEquals("((a = ? OR b = ?) AND c = ?) AND d = ?", conditionBuilder.build());
Assert.assertEquals(ListUtil.of("A", "B", "C", "D"), conditionBuilder.getParamValues());
Assert.assertEquals(ListUtil.view("A", "B", "C", "D"), conditionBuilder.getParamValues());
}
}