diff --git a/src/main/java/org/mybatis/dynamic/sql/util/StringUtilities.java b/src/main/java/org/mybatis/dynamic/sql/util/StringUtilities.java index 3104c2905..2b57c748e 100644 --- a/src/main/java/org/mybatis/dynamic/sql/util/StringUtilities.java +++ b/src/main/java/org/mybatis/dynamic/sql/util/StringUtilities.java @@ -58,6 +58,5 @@ static String toCamelCase(String inputString) { static String formatConstantForSQL(String in) { String escaped = in.replace("'", "''"); //$NON-NLS-1$ //$NON-NLS-2$ return "'" + escaped + "'"; //$NON-NLS-1$ //$NON-NLS-2$ - } } diff --git a/src/main/java/org/mybatis/dynamic/sql/util/Utilities.java b/src/main/java/org/mybatis/dynamic/sql/util/Utilities.java index 87ea18e12..0c3bd188f 100644 --- a/src/main/java/org/mybatis/dynamic/sql/util/Utilities.java +++ b/src/main/java/org/mybatis/dynamic/sql/util/Utilities.java @@ -15,23 +15,10 @@ */ package org.mybatis.dynamic.sql.util; -import java.util.Collection; -import java.util.Objects; -import java.util.stream.Stream; - -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; public interface Utilities { static long safelyUnbox(@Nullable Long l) { return l == null ? 0 : l; } - - static Stream<@NonNull T> filterNullValues(Stream<@Nullable T> values) { - return values.filter(Objects::nonNull); - } - - static Collection<@NonNull T> removeNullElements(Collection<@Nullable T> values) { - return filterNullValues(values.stream()).toList(); - } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java index 67f37951e..e521d28b2 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java @@ -70,8 +70,7 @@ public static IsInCaseInsensitive of(String... values) { } public static IsInCaseInsensitive of(Collection values) { - // Keep the null safe upper case utility for backwards compatibility - //noinspection DataFlowIssue - return new IsInCaseInsensitive(values).map(StringUtilities::safelyUpperCase); + // Keep the null safe upper case utility for backwards compatibility in case someone passes in a null + return new IsInCaseInsensitive(values.stream().map(StringUtilities::safelyUpperCase).toList()); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java index cff58415d..7d81bba69 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java @@ -18,13 +18,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Objects; import java.util.function.Predicate; import java.util.function.UnaryOperator; import org.jspecify.annotations.Nullable; import org.mybatis.dynamic.sql.AbstractListValueCondition; -import org.mybatis.dynamic.sql.util.StringUtilities; -import org.mybatis.dynamic.sql.util.Utilities; public class IsInCaseInsensitiveWhenPresent extends AbstractListValueCondition implements CaseInsensitiveRenderableCondition { @@ -35,8 +34,8 @@ public static IsInCaseInsensitiveWhenPresent empty() { return EMPTY; } - protected IsInCaseInsensitiveWhenPresent(Collection<@Nullable String> values) { - super(Utilities.removeNullElements(values)); + protected IsInCaseInsensitiveWhenPresent(Collection values) { + super(values); } @Override @@ -66,8 +65,7 @@ public static IsInCaseInsensitiveWhenPresent of(@Nullable String... values) { } public static IsInCaseInsensitiveWhenPresent of(Collection<@Nullable String> values) { - // Keep the null safe upper case utility for backwards compatibility - //noinspection DataFlowIssue - return new IsInCaseInsensitiveWhenPresent(values).map(StringUtilities::safelyUpperCase); + return new IsInCaseInsensitiveWhenPresent( + values.stream().filter(Objects::nonNull).map(String::toUpperCase).toList()); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsLikeCaseInsensitive.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsLikeCaseInsensitive.java index 4ebdb00fb..de8d72cd0 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsLikeCaseInsensitive.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsLikeCaseInsensitive.java @@ -67,8 +67,7 @@ public IsLikeCaseInsensitive map(UnaryOperator mapper) { } public static IsLikeCaseInsensitive of(String value) { - // Keep the null safe upper case utility for backwards compatibility - //noinspection DataFlowIssue - return new IsLikeCaseInsensitive(value).map(StringUtilities::safelyUpperCase); + // Keep the null safe upper case utility for backwards compatibility in case someone passes in a null + return new IsLikeCaseInsensitive(StringUtilities.safelyUpperCase(value)); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java index f5f970c45..c956b4d55 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java @@ -70,8 +70,7 @@ public static IsNotInCaseInsensitive of(String... values) { } public static IsNotInCaseInsensitive of(Collection values) { - // Keep the null safe upper case utility for backwards compatibility - //noinspection DataFlowIssue - return new IsNotInCaseInsensitive(values).map(StringUtilities::safelyUpperCase); + // Keep the null safe upper case utility for backwards compatibility in case someone passes in a null + return new IsNotInCaseInsensitive(values.stream().map(StringUtilities::safelyUpperCase).toList()); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java index a8873a7e4..9202a2ad1 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java @@ -18,13 +18,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Objects; import java.util.function.Predicate; import java.util.function.UnaryOperator; import org.jspecify.annotations.Nullable; import org.mybatis.dynamic.sql.AbstractListValueCondition; -import org.mybatis.dynamic.sql.util.StringUtilities; -import org.mybatis.dynamic.sql.util.Utilities; public class IsNotInCaseInsensitiveWhenPresent extends AbstractListValueCondition implements CaseInsensitiveRenderableCondition { @@ -35,8 +34,8 @@ public static IsNotInCaseInsensitiveWhenPresent empty() { return EMPTY; } - protected IsNotInCaseInsensitiveWhenPresent(Collection<@Nullable String> values) { - super(Utilities.removeNullElements(values)); + protected IsNotInCaseInsensitiveWhenPresent(Collection values) { + super(values); } @Override @@ -66,8 +65,7 @@ public static IsNotInCaseInsensitiveWhenPresent of(@Nullable String... values) { } public static IsNotInCaseInsensitiveWhenPresent of(Collection<@Nullable String> values) { - // Keep the null safe upper case utility for backwards compatibility - //noinspection DataFlowIssue - return new IsNotInCaseInsensitiveWhenPresent(values).map(StringUtilities::safelyUpperCase); + return new IsNotInCaseInsensitiveWhenPresent( + values.stream().filter(Objects::nonNull).map(String::toUpperCase).toList()); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotLikeCaseInsensitive.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotLikeCaseInsensitive.java index 1fb6847c0..c26168e42 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotLikeCaseInsensitive.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotLikeCaseInsensitive.java @@ -69,8 +69,7 @@ public IsNotLikeCaseInsensitive map(UnaryOperator mapper) { } public static IsNotLikeCaseInsensitive of(String value) { - // Keep the null safe upper case utility for backwards compatibility - //noinspection DataFlowIssue - return new IsNotLikeCaseInsensitive(value).map(StringUtilities::safelyUpperCase); + // Keep the null safe upper case utility for backwards compatibility in case someone passes in a null + return new IsNotLikeCaseInsensitive(StringUtilities.safelyUpperCase(value)); } }