public <R> void queryWithPassThrough(String out,String tableName,String time, Class<R> type, BiFunction<String,String,Integer> dbFallback1,
Function<String, Integer> dbFallback, Consumer<List<R>> consumer,
Predicate<Integer> predicate){
Integer i1 = dbFallback1.apply(tableName,time);
System.out.println("查询删除条数"+i1);
List<R> list = JSONUtil.toList(out, type);
List<List<R>> split = CollUtil.split(list, 1);
split.forEach(consumer);
System.out.println("插入完成");
Integer apply =dbFallback.apply(tableName);
System.out.println("查询插入后的条数");
if(predicate.test(apply)){
System.out.println("判断同步的条数是否等于插入的条数");
};
}
@Test
void testSimpleFactoryModel1() {
JSONObject info1 = new JSONObject();
info1.put("name", "张三");
info1.put("age", "18");
JSONObject info2 = new JSONObject();
info2.put("name", "李四");
info2.put("age", "19");
//把上面创建的两个json对象加入到json数组里
JSONArray array = new JSONArray();
array.add(info1);
array.add(info2);
String jsonStr = JSONUtil.toJsonStr(array);
System.out.println(jsonStr);
queryWithPassThrough(jsonStr,"777777","77",
Map.class,
(s, s2) -> 777777,
s -> Integer.valueOf(s),
maps -> System.out.println(maps),
integer ->
ObjectUtil.equals(2,integer)
);
}
java8 一些函数式伪代码
最新推荐文章于 2025-06-04 17:43:56 发布