1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.dynamic.sql.where.condition;
17
18 import java.util.Arrays;
19 import java.util.Collection;
20 import java.util.Collections;
21 import java.util.function.Function;
22 import java.util.function.Predicate;
23
24 import org.mybatis.dynamic.sql.AbstractListValueCondition;
25 import org.mybatis.dynamic.sql.render.RenderingContext;
26 import org.mybatis.dynamic.sql.util.StringUtilities;
27 import org.mybatis.dynamic.sql.util.Validator;
28
29 public class IsNotInCaseInsensitive<T> extends AbstractListValueCondition<T>
30 implements CaseInsensitiveRenderableCondition<T>, AbstractListValueCondition.Filterable<T>,
31 AbstractListValueCondition.Mappable<T> {
32 private static final IsNotInCaseInsensitive<?> EMPTY = new IsNotInCaseInsensitive<>(Collections.emptyList());
33
34 public static <T> IsNotInCaseInsensitive<T> empty() {
35 @SuppressWarnings("unchecked")
36 IsNotInCaseInsensitive<T> t = (IsNotInCaseInsensitive<T>) EMPTY;
37 return t;
38 }
39
40 protected IsNotInCaseInsensitive(Collection<T> values) {
41 super(values.stream().map(StringUtilities::upperCaseIfPossible).toList());
42 }
43
44 @Override
45 public boolean shouldRender(RenderingContext renderingContext) {
46 Validator.assertNotEmpty(values, "ERROR.44", "IsNotInCaseInsensitive");
47 return true;
48 }
49
50 @Override
51 public String operator() {
52 return "not in";
53 }
54
55 @Override
56 public IsNotInCaseInsensitive<T> filter(Predicate<? super T> predicate) {
57 return filterSupport(predicate, IsNotInCaseInsensitive::new, this, IsNotInCaseInsensitive::empty);
58 }
59
60 @Override
61 public <R> IsNotInCaseInsensitive<R> map(Function<? super T, ? extends R> mapper) {
62 return mapSupport(mapper, IsNotInCaseInsensitive::new, IsNotInCaseInsensitive::empty);
63 }
64
65 @SafeVarargs
66 public static <T> IsNotInCaseInsensitive<T> of(T... values) {
67 return of(Arrays.asList(values));
68 }
69
70 public static <T> IsNotInCaseInsensitive<T> of(Collection<T> values) {
71 return new IsNotInCaseInsensitive<>(values);
72 }
73 }