Skip to content

Commit f1ccf48

Browse files
committed
Merge branch 'master' into improve-conditions
# Conflicts: # src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java # src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java # src/main/java/org/mybatis/dynamic/sql/where/condition/IsLikeCaseInsensitive.java # src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java # src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java # src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotLikeCaseInsensitive.java
2 parents d73b31b + 7b20327 commit f1ccf48

File tree

8 files changed

+18
-40
lines changed

8 files changed

+18
-40
lines changed

src/main/java/org/mybatis/dynamic/sql/util/StringUtilities.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,5 @@ static String toCamelCase(String inputString) {
5858
static String formatConstantForSQL(String in) {
5959
String escaped = in.replace("'", "''"); //$NON-NLS-1$ //$NON-NLS-2$
6060
return "'" + escaped + "'"; //$NON-NLS-1$ //$NON-NLS-2$
61-
6261
}
6362
}

src/main/java/org/mybatis/dynamic/sql/util/Utilities.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,10 @@
1515
*/
1616
package org.mybatis.dynamic.sql.util;
1717

18-
import java.util.Collection;
19-
import java.util.Objects;
20-
import java.util.stream.Stream;
21-
22-
import org.jspecify.annotations.NonNull;
2318
import org.jspecify.annotations.Nullable;
2419

2520
public interface Utilities {
2621
static long safelyUnbox(@Nullable Long l) {
2722
return l == null ? 0 : l;
2823
}
29-
30-
static <T> Stream<@NonNull T> filterNullValues(Stream<@Nullable T> values) {
31-
return values.filter(Objects::nonNull);
32-
}
33-
34-
static <T> Collection<@NonNull T> removeNullElements(Collection<@Nullable T> values) {
35-
return filterNullValues(values.stream()).toList();
36-
}
3724
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public static IsInCaseInsensitive<String> of(String... values) {
6666
}
6767

6868
public static IsInCaseInsensitive<String> of(Collection<String> values) {
69-
// Keep the null safe upper case utility for backwards compatibility
70-
//noinspection DataFlowIssue
71-
return new IsInCaseInsensitive<>(values).map(StringUtilities::safelyUpperCase);
69+
// Keep the null safe upper case utility for backwards compatibility in case someone passes in a null
70+
return new IsInCaseInsensitive<>(values.stream().map(StringUtilities::safelyUpperCase).toList());
7271
}
7372
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
import java.util.Collection;
2020
import java.util.Collections;
2121
import java.util.function.Function;
22+
import java.util.Objects;
2223
import java.util.function.Predicate;
2324

2425
import org.jspecify.annotations.Nullable;
2526
import org.mybatis.dynamic.sql.AbstractListValueCondition;
26-
import org.mybatis.dynamic.sql.util.StringUtilities;
27-
import org.mybatis.dynamic.sql.util.Utilities;
2827

2928
public class IsInCaseInsensitiveWhenPresent<T> extends AbstractListValueCondition<T>
3029
implements CaseInsensitiveRenderableCondition<T> {
@@ -37,8 +36,8 @@ public static <T> IsInCaseInsensitiveWhenPresent<T> empty() {
3736
return t;
3837
}
3938

40-
protected IsInCaseInsensitiveWhenPresent(Collection<@Nullable T> values) {
41-
super(Utilities.removeNullElements(values));
39+
protected IsInCaseInsensitiveWhenPresent(Collection<String> values) {
40+
super(values);
4241
}
4342

4443
@Override
@@ -62,8 +61,7 @@ public static IsInCaseInsensitiveWhenPresent<String> of(@Nullable String... valu
6261
}
6362

6463
public static IsInCaseInsensitiveWhenPresent<String> of(Collection<@Nullable String> values) {
65-
// Keep the null safe upper case utility for backwards compatibility
66-
//noinspection DataFlowIssue
67-
return new IsInCaseInsensitiveWhenPresent<>(values).map(StringUtilities::safelyUpperCase);
64+
return new IsInCaseInsensitiveWhenPresent<>(
65+
values.stream().filter(Objects::nonNull).map(String::toUpperCase).toList());
6866
}
6967
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsLikeCaseInsensitive.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public <R> IsLikeCaseInsensitive<R> map(Function<? super T, ? extends R> mapper)
6262
}
6363

6464
public static IsLikeCaseInsensitive<String> of(String value) {
65-
// Keep the null safe upper case utility for backwards compatibility
66-
//noinspection DataFlowIssue
67-
return new IsLikeCaseInsensitive<>(value).map(StringUtilities::safelyUpperCase);
65+
// Keep the null safe upper case utility for backwards compatibility in case someone passes in a null
66+
return new IsLikeCaseInsensitive<>(StringUtilities.safelyUpperCase(value));
6867
}
6968
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public static IsNotInCaseInsensitive<String> of(String... values) {
6666
}
6767

6868
public static IsNotInCaseInsensitive<String> of(Collection<String> values) {
69-
// Keep the null safe upper case utility for backwards compatibility
70-
//noinspection DataFlowIssue
71-
return new IsNotInCaseInsensitive<>(values).map(StringUtilities::safelyUpperCase);
69+
// Keep the null safe upper case utility for backwards compatibility in case someone passes in a null
70+
return new IsNotInCaseInsensitive<>(values.stream().map(StringUtilities::safelyUpperCase).toList());
7271
}
7372
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
import java.util.Collection;
2020
import java.util.Collections;
2121
import java.util.function.Function;
22+
import java.util.Objects;
2223
import java.util.function.Predicate;
2324

2425
import org.jspecify.annotations.Nullable;
2526
import org.mybatis.dynamic.sql.AbstractListValueCondition;
26-
import org.mybatis.dynamic.sql.util.StringUtilities;
27-
import org.mybatis.dynamic.sql.util.Utilities;
2827

2928
public class IsNotInCaseInsensitiveWhenPresent<T> extends AbstractListValueCondition<T>
3029
implements CaseInsensitiveRenderableCondition<T> {
@@ -37,8 +36,8 @@ public static <T> IsNotInCaseInsensitiveWhenPresent<T> empty() {
3736
return t;
3837
}
3938

40-
protected IsNotInCaseInsensitiveWhenPresent(Collection<@Nullable T> values) {
41-
super(Utilities.removeNullElements(values));
39+
protected IsNotInCaseInsensitiveWhenPresent(Collection<String> values) {
40+
super(values);
4241
}
4342

4443
@Override
@@ -62,8 +61,7 @@ public static IsNotInCaseInsensitiveWhenPresent<String> of(@Nullable String... v
6261
}
6362

6463
public static IsNotInCaseInsensitiveWhenPresent<String> of(Collection<@Nullable String> values) {
65-
// Keep the null safe upper case utility for backwards compatibility
66-
//noinspection DataFlowIssue
67-
return new IsNotInCaseInsensitiveWhenPresent<>(values).map(StringUtilities::safelyUpperCase);
64+
return new IsNotInCaseInsensitiveWhenPresent<>(
65+
values.stream().filter(Objects::nonNull).map(String::toUpperCase).toList());
6866
}
6967
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotLikeCaseInsensitive.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ public <R> IsNotLikeCaseInsensitive<R> map(Function<? super T, ? extends R> mapp
7171
}
7272

7373
public static IsNotLikeCaseInsensitive<String> of(String value) {
74-
// Keep the null safe upper case utility for backwards compatibility
75-
//noinspection DataFlowIssue
76-
return new IsNotLikeCaseInsensitive<>(value).map(StringUtilities::safelyUpperCase);
74+
// Keep the null safe upper case utility for backwards compatibility in case someone passes in a null
75+
return new IsNotLikeCaseInsensitive<>(StringUtilities.safelyUpperCase(value));
7776
}
7877
}

0 commit comments

Comments
 (0)