Skip to content

Commit f7c631d

Browse files
ydqabel533
authored andcommitted
ExampleWrapper condition 系列方法新增 Supplier 重载
1 parent d1f4ab8 commit f7c631d

File tree

1 file changed

+192
-0
lines changed

1 file changed

+192
-0
lines changed

mapper/src/main/java/io/mybatis/mapper/example/ExampleWrapper.java

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,19 @@ public ExampleWrapper<T, I> set(boolean useSet, Fn<T, Object> fn, Object value)
186186
return useSet ? set(fn, value) : this;
187187
}
188188

189+
190+
/**
191+
* 设置更新字段和值
192+
*
193+
* @param useSet 表达式条件, true 使用,false 不使用
194+
* @param fn 字段
195+
* @param supplier 值构造函数
196+
*/
197+
public ExampleWrapper<T, I> set(boolean useSet, Fn<T, Object> fn, Supplier<Object> supplier) {
198+
return useSet ? set(fn, supplier.get()) : this;
199+
}
200+
201+
189202
/**
190203
* 设置更新字段和值
191204
*
@@ -248,6 +261,17 @@ public ExampleWrapper<T, I> eq(boolean useCondition, Fn<T, Object> fn, Object va
248261
return useCondition ? eq(fn, value) : this;
249262
}
250263

264+
/**
265+
* 字段 = 值
266+
*
267+
* @param useCondition 表达式条件, true 使用,false 不使用
268+
* @param fn 字段对应的 get 方法引用
269+
* @param supplier 值构造函数
270+
*/
271+
public ExampleWrapper<T, I> eq(boolean useCondition, Fn<T, Object> fn, Supplier<Object> supplier) {
272+
return useCondition ? eq(fn, supplier.get()) : this;
273+
}
274+
251275
/**
252276
* 字段 = 值
253277
*
@@ -259,6 +283,17 @@ public ExampleWrapper<T, I> eq(Fn<T, Object> fn, Object value) {
259283
return this;
260284
}
261285

286+
/**
287+
* 字段 != 值
288+
*
289+
* @param useCondition 表达式条件, true 使用,false 不使用
290+
* @param fn 字段对应的 get 方法引用
291+
* @param supplier 值构造函数
292+
*/
293+
public ExampleWrapper<T, I> ne(boolean useCondition, Fn<T, Object> fn, Supplier<Object> supplier) {
294+
return useCondition ? ne(fn, supplier.get()) : this;
295+
}
296+
262297
/**
263298
* 字段 != 值
264299
*
@@ -281,6 +316,17 @@ public ExampleWrapper<T, I> ne(Fn<T, Object> fn, Object value) {
281316
return this;
282317
}
283318

319+
/**
320+
* 字段 > 值
321+
*
322+
* @param useCondition 表达式条件, true 使用,false 不使用
323+
* @param fn 字段对应的 get 方法引用
324+
* @param supplier 值构造函数
325+
*/
326+
public ExampleWrapper<T, I> gt(boolean useCondition, Fn<T, Object> fn, Supplier<Object> supplier) {
327+
return useCondition ? gt(fn, supplier.get()) : this;
328+
}
329+
284330
/**
285331
* 字段 > 值
286332
*
@@ -303,6 +349,17 @@ public ExampleWrapper<T, I> gt(Fn<T, Object> fn, Object value) {
303349
return this;
304350
}
305351

352+
/**
353+
* 字段 >= 值
354+
*
355+
* @param useCondition 表达式条件, true 使用,false 不使用
356+
* @param fn 字段对应的 get 方法引用
357+
* @param supplier 值构造函数
358+
*/
359+
public ExampleWrapper<T, I> ge(boolean useCondition, Fn<T, Object> fn, Supplier<Object> supplier) {
360+
return useCondition ? ge(fn, supplier.get()) : this;
361+
}
362+
306363
/**
307364
* 字段 >= 值
308365
*
@@ -325,6 +382,16 @@ public ExampleWrapper<T, I> ge(Fn<T, Object> fn, Object value) {
325382
return this;
326383
}
327384

385+
/**
386+
* 字段 < 值
387+
*
388+
* @param useCondition 表达式条件, true 使用,false 不使用
389+
* @param fn 字段对应的 get 方法引用
390+
*/
391+
public ExampleWrapper<T, I> lt(boolean useCondition, Fn<T, Object> fn, Supplier<Object> supplier) {
392+
return useCondition ? lt(fn, supplier.get()) : this;
393+
}
394+
328395
/**
329396
* 字段 < 值
330397
*
@@ -358,6 +425,17 @@ public ExampleWrapper<T, I> le(boolean useCondition, Fn<T, Object> fn, Object va
358425
return useCondition ? le(fn, value) : this;
359426
}
360427

428+
/**
429+
* 字段 <= 值
430+
*
431+
* @param useCondition 表达式条件, true 使用,false 不使用
432+
* @param fn 字段对应的 get 方法引用
433+
* @param supplier 值构造函数
434+
*/
435+
public ExampleWrapper<T, I> le(boolean useCondition, Fn<T, Object> fn, Supplier<Object> supplier) {
436+
return useCondition ? le(fn, supplier.get()) : this;
437+
}
438+
361439
/**
362440
* 字段 <= 值
363441
*
@@ -381,6 +459,18 @@ public ExampleWrapper<T, I> in(boolean useCondition, Fn<T, Object> fn, Iterable
381459
return useCondition ? in(fn, values) : this;
382460
}
383461

462+
/**
463+
* 字段 in (值集合)
464+
*
465+
* @param useCondition 表达式条件, true 使用,false 不使用
466+
* @param fn 字段对应的 get 方法引用
467+
* @param supplier 值集合构造函数
468+
*/
469+
@SuppressWarnings("rawtypes")
470+
public ExampleWrapper<T, I> in(boolean useCondition, Fn<T, Object> fn, Supplier<Iterable> supplier) {
471+
return useCondition ? in(fn, supplier.get()) : this;
472+
}
473+
384474
/**
385475
* 字段 in (值集合)
386476
*
@@ -405,6 +495,18 @@ public ExampleWrapper<T, I> notIn(boolean useCondition, Fn<T, Object> fn, Iterab
405495
return useCondition ? notIn(fn, values) : this;
406496
}
407497

498+
/**
499+
* 字段 not in (值集合)
500+
*
501+
* @param useCondition 表达式条件, true 使用,false 不使用
502+
* @param fn 字段对应的 get 方法引用
503+
* @param supplier 值集合构造函数
504+
*/
505+
@SuppressWarnings("rawtypes")
506+
public ExampleWrapper<T, I> notIn(boolean useCondition, Fn<T, Object> fn, Supplier<Iterable> supplier) {
507+
return useCondition ? notIn(fn, supplier.get()) : this;
508+
}
509+
408510
/**
409511
* 字段 not in (值集合)
410512
*
@@ -429,6 +531,18 @@ public ExampleWrapper<T, I> between(boolean useCondition, Fn<T, Object> fn, Obje
429531
return useCondition ? between(fn, value1, value2) : this;
430532
}
431533

534+
/**
535+
* 字段 between value1 and value 2
536+
*
537+
* @param useCondition 表达式条件, true 使用,false 不使用
538+
* @param fn 字段对应的 get 方法引用
539+
* @param supplier1 值1构造函数
540+
* @param supplier2 值2构造函数
541+
*/
542+
public ExampleWrapper<T, I> between(boolean useCondition, Fn<T, Object> fn, Supplier<Object> supplier1, Supplier<Object> supplier2) {
543+
return useCondition ? between(fn, supplier1.get(), supplier2.get()) : this;
544+
}
545+
432546
/**
433547
* 字段 between value1 and value 2
434548
*
@@ -453,6 +567,18 @@ public ExampleWrapper<T, I> notBetween(boolean useCondition, Fn<T, Object> fn, O
453567
return useCondition ? notBetween(fn, value1, value2) : this;
454568
}
455569

570+
/**
571+
* 字段 not between value1 and value 2
572+
*
573+
* @param useCondition 表达式条件, true 使用,false 不使用
574+
* @param fn 字段对应的 get 方法引用
575+
* @param supplier1 值1构造函数
576+
* @param supplier2 值2构造函数
577+
*/
578+
public ExampleWrapper<T, I> notBetween(boolean useCondition, Fn<T, Object> fn, Supplier<Object> supplier1, Supplier<Object> supplier2) {
579+
return useCondition ? notBetween(fn, supplier1.get(), supplier2.get()) : this;
580+
}
581+
456582
/**
457583
* 字段 not between value1 and value 2
458584
*
@@ -476,6 +602,17 @@ public ExampleWrapper<T, I> contains(boolean useCondition, Fn<T, Object> fn, Str
476602
return useCondition ? contains(fn, value) : this;
477603
}
478604

605+
/**
606+
* 字段 like %值%
607+
*
608+
* @param useCondition 表达式条件, true 使用,false 不使用
609+
* @param fn 字段对应的 get 方法引用
610+
* @param supplier 值构造函数,两侧自动添加 %
611+
*/
612+
public ExampleWrapper<T, I> contains(boolean useCondition, Fn<T, Object> fn, Supplier<String> supplier) {
613+
return useCondition ? contains(fn, supplier.get()) : this;
614+
}
615+
479616
/**
480617
* 字段 like %值%
481618
*
@@ -498,6 +635,17 @@ public ExampleWrapper<T, I> startsWith(boolean useCondition, Fn<T, Object> fn, S
498635
return useCondition ? startsWith(fn, value) : this;
499636
}
500637

638+
/**
639+
* 字段 like 值%,匹配 value 为前缀的值
640+
*
641+
* @param useCondition 表达式条件, true 使用,false 不使用
642+
* @param fn 字段对应的 get 方法引用
643+
* @param supplier 值构造函数,右侧自动添加 %
644+
*/
645+
public ExampleWrapper<T, I> startsWith(boolean useCondition, Fn<T, Object> fn, Supplier<String> supplier) {
646+
return useCondition ? startsWith(fn, supplier.get()) : this;
647+
}
648+
501649
/**
502650
* 字段 like 值%,匹配 value 为前缀的值
503651
*
@@ -520,6 +668,17 @@ public ExampleWrapper<T, I> endsWith(boolean useCondition, Fn<T, Object> fn, Str
520668
return useCondition ? endsWith(fn, value) : this;
521669
}
522670

671+
/**
672+
* 字段 like %值,匹配 value 为后缀的值
673+
*
674+
* @param useCondition 表达式条件, true 使用,false 不使用
675+
* @param fn 字段对应的 get 方法引用
676+
* @param supplier 值构造函数,左侧自动添加 %
677+
*/
678+
public ExampleWrapper<T, I> endsWith(boolean useCondition, Fn<T, Object> fn, Supplier<String> supplier) {
679+
return useCondition ? endsWith(fn, supplier.get()) : this;
680+
}
681+
523682
/**
524683
* 字段 like %值,匹配 value 为后缀的值
525684
*
@@ -542,6 +701,17 @@ public ExampleWrapper<T, I> like(boolean useCondition, Fn<T, Object> fn, String
542701
return useCondition ? like(fn, value) : this;
543702
}
544703

704+
/**
705+
* 字段 like 值
706+
*
707+
* @param useCondition 表达式条件, true 使用,false 不使用
708+
* @param fn 字段对应的 get 方法引用
709+
* @param supplier 值构造函数,需要指定 '%'(多个), '_'(单个) 模糊匹配
710+
*/
711+
public ExampleWrapper<T, I> like(boolean useCondition, Fn<T, Object> fn, Supplier<String> supplier) {
712+
return useCondition ? like(fn, supplier.get()) : this;
713+
}
714+
545715
/**
546716
* 字段 like 值
547717
*
@@ -564,6 +734,17 @@ public ExampleWrapper<T, I> notLike(boolean useCondition, Fn<T, Object> fn, Stri
564734
return useCondition ? notLike(fn, value) : this;
565735
}
566736

737+
/**
738+
* 字段 not like 值
739+
*
740+
* @param useCondition 表达式条件, true 使用,false 不使用
741+
* @param fn 字段对应的 get 方法引用
742+
* @param supplier 值构造函数,需要指定 % 模糊匹配
743+
*/
744+
public ExampleWrapper<T, I> notLike(boolean useCondition, Fn<T, Object> fn, Supplier<String> supplier) {
745+
return useCondition ? notLike(fn, supplier.get()) : this;
746+
}
747+
567748
/**
568749
* 字段 not like 值
569750
*
@@ -606,6 +787,17 @@ public ExampleWrapper<T, I> anyCondition(boolean useCondition, String condition,
606787
return useCondition ? anyCondition(condition, value) : this;
607788
}
608789

790+
/**
791+
* 手写左边条件,右边用value值
792+
*
793+
* @param useCondition 表达式条件, true 使用,false 不使用
794+
* @param condition 例如 "length(countryname)="
795+
* @param supplier 任意条件值的构造函数
796+
*/
797+
public ExampleWrapper<T, I> anyCondition(boolean useCondition, String condition, Supplier<Object> supplier) {
798+
return useCondition ? anyCondition(condition, supplier.get()) : this;
799+
}
800+
609801
/**
610802
* 手写左边条件,右边用value值
611803
*

0 commit comments

Comments
 (0)