Revert "增强ActiveEntity,使其可以使用getter对应的lambda取值或设置条件"

This reverts commit cbebecda58.
This commit is contained in:
VampireAchao 2022-03-16 09:16:54 +08:00
parent e1de291063
commit f34a3e9c88
2 changed files with 0 additions and 43 deletions

View File

@ -1,35 +0,0 @@
package cn.hutool.db;
import cn.hutool.core.lang.func.Func1;
import cn.hutool.core.lang.func.LambdaUtil;
/**
* 支持lambda的Entity
*
* @author VampireAchao
*/
public class LambdaEntity<T> extends ActiveEntity {
public LambdaEntity(T entity) {
super(parse(entity));
}
@SuppressWarnings("unchecked")
public <R> R get(Func1<T, R> field) {
return (R) super.get(LambdaUtil.getFieldName(field));
}
@SuppressWarnings("unchecked")
public LambdaEntity<T> set(Func1<T, ?> field, Object value) {
return (LambdaEntity<T>) super.set(LambdaUtil.getFieldName(field), value);
}
@SuppressWarnings("unchecked")
public LambdaEntity<T> setIgnoreNull(Func1<T, ?> field, Object value) {
if (null != field && null != value) {
return (LambdaEntity<T>) set(LambdaUtil.getFieldName(field), value);
}
return this;
}
}

View File

@ -120,14 +120,6 @@ public class CRUDTest {
Assert.assertFalse(entity.isEmpty());
}
@Test
public void lambdaSetTest() {
LambdaEntity<User> entity = new LambdaEntity<>(new User());
entity.set(User::getAge, 66).load();
Assert.assertEquals(new Integer(66), entity.get(User::getAge));
Assert.assertFalse(entity.isEmpty());
}
/**
* 对增删改查做单元测试
*