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.Objects;
22 import java.util.function.Predicate;
23 import java.util.function.UnaryOperator;
24 import java.util.stream.Collectors;
25
26 import org.mybatis.dynamic.sql.AbstractListValueCondition;
27 import org.mybatis.dynamic.sql.util.StringUtilities;
28
29 public class IsInCaseInsensitiveWhenPresent extends AbstractListValueCondition<String>
30 implements CaseInsensitiveVisitableCondition {
31 private static final IsInCaseInsensitiveWhenPresent EMPTY = new IsInCaseInsensitiveWhenPresent(Collections.emptyList());
32
33 public static IsInCaseInsensitiveWhenPresent empty() {
34 return EMPTY;
35 }
36
37 protected IsInCaseInsensitiveWhenPresent(Collection<String> values) {
38 super(values.stream().filter(Objects::nonNull).collect(Collectors.toList()));
39 }
40
41 @Override
42 public String operator() {
43 return "in";
44 }
45
46 @Override
47 public IsInCaseInsensitiveWhenPresent filter(Predicate<? super String> predicate) {
48 return filterSupport(predicate, IsInCaseInsensitiveWhenPresent::new, this, IsInCaseInsensitiveWhenPresent::empty);
49 }
50
51
52
53
54
55
56
57
58 public IsInCaseInsensitiveWhenPresent map(UnaryOperator<String> mapper) {
59 return mapSupport(mapper, IsInCaseInsensitiveWhenPresent::new, IsInCaseInsensitiveWhenPresent::empty);
60 }
61
62 public static IsInCaseInsensitiveWhenPresent of(String... values) {
63 return of(Arrays.asList(values));
64 }
65
66 public static IsInCaseInsensitiveWhenPresent of(Collection<String> values) {
67 return new IsInCaseInsensitiveWhenPresent(values).map(StringUtilities::safelyUpperCase);
68 }
69 }