Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.jspecify.annotations.NonNull;
import org.mybatis.dynamic.sql.render.RenderedParameterInfo;
import org.mybatis.dynamic.sql.render.RenderingContext;
import org.mybatis.dynamic.sql.util.FragmentAndParameters;
Expand Down Expand Up @@ -114,7 +113,7 @@ public interface Filterable<T> {
* @return this condition if renderable and the value matches the predicate, otherwise a condition
* that will not render.
*/
AbstractListValueCondition<T> filter(Predicate<? super @NonNull T> predicate);
AbstractListValueCondition<T> filter(Predicate<? super T> predicate);
}

/**
Expand All @@ -139,6 +138,6 @@ public interface Mappable<T> {
* @return a new condition with the result of applying the mapper to the value of this condition,
* if renderable, otherwise a condition that will not render.
*/
<R> AbstractListValueCondition<R> map(Function<? super @NonNull T, ? extends R> mapper);
<R> AbstractListValueCondition<R> map(Function<? super T, ? extends R> mapper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.function.Predicate;
import java.util.function.Supplier;

import org.jspecify.annotations.NonNull;
import org.mybatis.dynamic.sql.render.RenderedParameterInfo;
import org.mybatis.dynamic.sql.render.RenderingContext;
import org.mybatis.dynamic.sql.util.FragmentAndParameters;
Expand Down Expand Up @@ -89,7 +88,7 @@ public interface Filterable<T> {
* @return this condition if renderable and the value matches the predicate, otherwise a condition
* that will not render.
*/
AbstractSingleValueCondition<T> filter(Predicate<? super @NonNull T> predicate);
AbstractSingleValueCondition<T> filter(Predicate<? super T> predicate);
}

/**
Expand All @@ -114,6 +113,6 @@ public interface Mappable<T> {
* @return a new condition with the result of applying the mapper to the value of this condition,
* if renderable, otherwise a condition that will not render.
*/
<R> AbstractSingleValueCondition<R> map(Function<? super @NonNull T, ? extends R> mapper);
<R> AbstractSingleValueCondition<R> map(Function<? super T, ? extends R> mapper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.function.Predicate;
import java.util.function.Supplier;

import org.jspecify.annotations.NonNull;
import org.mybatis.dynamic.sql.render.RenderedParameterInfo;
import org.mybatis.dynamic.sql.render.RenderingContext;
import org.mybatis.dynamic.sql.util.FragmentAndParameters;
Expand Down Expand Up @@ -111,7 +110,7 @@ public interface Filterable<T> {
* @return this condition if renderable and the values match the predicate, otherwise a condition
* that will not render.
*/
AbstractTwoValueCondition<T> filter(BiPredicate<? super @NonNull T, ? super @NonNull T> predicate);
AbstractTwoValueCondition<T> filter(BiPredicate<? super T, ? super T> predicate);

/**
* If renderable and both values match the predicate, returns this condition. Else returns a condition
Expand All @@ -122,7 +121,7 @@ public interface Filterable<T> {
* @return this condition if renderable and the values match the predicate, otherwise a condition
* that will not render.
*/
AbstractTwoValueCondition<T> filter(Predicate<? super @NonNull T> predicate);
AbstractTwoValueCondition<T> filter(Predicate<? super T> predicate);
}

/**
Expand All @@ -148,8 +147,8 @@ public interface Mappable<T> {
* @return a new condition with the result of applying the mappers to the values of this condition,
* if renderable, otherwise a condition that will not render.
*/
<R> AbstractTwoValueCondition<R> map(Function<? super @NonNull T, ? extends R> mapper1,
Function<? super @NonNull T, ? extends R> mapper2);
<R> AbstractTwoValueCondition<R> map(Function<? super T, ? extends R> mapper1,
Function<? super T, ? extends R> mapper2);

/**
* If renderable, apply the mapping to both values and return a new condition with the new values. Else return a
Expand All @@ -160,6 +159,6 @@ <R> AbstractTwoValueCondition<R> map(Function<? super @NonNull T, ? extends R> m
* @return a new condition with the result of applying the mappers to the values of this condition,
* if renderable, otherwise a condition that will not render.
*/
<R> AbstractTwoValueCondition<R> map(Function<? super @NonNull T, ? extends R> mapper);
<R> AbstractTwoValueCondition<R> map(Function<? super T, ? extends R> mapper);
}
}
13 changes: 6 additions & 7 deletions src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.Objects;
import java.util.function.Supplier;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.DeleteModel;
Expand Down Expand Up @@ -782,11 +781,11 @@ static <T> IsLessThanOrEqualToWhenPresent<T> isLessThanOrEqualToWhenPresent(Supp
}

@SafeVarargs
static <T> IsIn<T> isIn(@NonNull T... values) {
static <T> IsIn<T> isIn(T... values) {
return IsIn.of(values);
}

static <T> IsIn<T> isIn(Collection<@NonNull T> values) {
static <T> IsIn<T> isIn(Collection<T> values) {
return IsIn.of(values);
}

Expand All @@ -804,11 +803,11 @@ static <T> IsInWhenPresent<T> isInWhenPresent(@Nullable Collection<@Nullable T>
}

@SafeVarargs
static <T> IsNotIn<T> isNotIn(@NonNull T... values) {
static <T> IsNotIn<T> isNotIn(T... values) {
return IsNotIn.of(values);
}

static <T> IsNotIn<T> isNotIn(Collection<@NonNull T> values) {
static <T> IsNotIn<T> isNotIn(Collection<T> values) {
return IsNotIn.of(values);
}

Expand All @@ -829,7 +828,7 @@ static <T> IsBetween.Builder<T> isBetween(T value1) {
return IsBetween.isBetween(value1);
}

static <T> IsBetween.Builder<T> isBetween(Supplier<@NonNull T> valueSupplier1) {
static <T> IsBetween.Builder<T> isBetween(Supplier<T> valueSupplier1) {
return isBetween(valueSupplier1.get());
}

Expand All @@ -845,7 +844,7 @@ static <T> IsNotBetween.Builder<T> isNotBetween(T value1) {
return IsNotBetween.isNotBetween(value1);
}

static <T> IsNotBetween.Builder<T> isNotBetween(Supplier<@NonNull T> valueSupplier1) {
static <T> IsNotBetween.Builder<T> isNotBetween(Supplier<T> valueSupplier1) {
return isNotBetween(valueSupplier1.get());
}

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/mybatis/dynamic/sql/util/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@
*/
package org.mybatis.dynamic.sql.util;

import java.util.Collection;
import java.util.Objects;
import java.util.stream.Stream;

import org.jspecify.annotations.Nullable;

public interface Utilities {
static long safelyUnbox(@Nullable Long l) {
return l == null ? 0 : l;
}

static <T> Stream<T> filterNulls(Collection<@Nullable T> values) {
// this method helps IntelliJ understand intended nullability
return values.stream().filter(Objects::nonNull);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

import java.util.function.Supplier;

import org.jspecify.annotations.NonNull;

/**
* Utility class supporting the "and" part of a between condition. This class supports builders, so it is mutable.
*
Expand All @@ -40,7 +38,7 @@ public R and(T value2) {
return build(value2);
}

public R and(Supplier<@NonNull T> valueSupplier2) {
public R and(Supplier<T> valueSupplier2) {
return and(valueSupplier2.get());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
import java.util.function.Function;
import java.util.function.Predicate;

import org.jspecify.annotations.NonNull;
import org.mybatis.dynamic.sql.AbstractTwoValueCondition;

public class IsBetween<T> extends AbstractTwoValueCondition<@NonNull T>
public class IsBetween<T> extends AbstractTwoValueCondition<T>
implements AbstractTwoValueCondition.Filterable<T>, AbstractTwoValueCondition.Mappable<T> {
private static final IsBetween<?> EMPTY = new IsBetween<Object>(-1, -1) {
@Override
Expand Down Expand Up @@ -63,23 +62,23 @@ public String operator2() {
}

@Override
public IsBetween<T> filter(BiPredicate<? super @NonNull T, ? super @NonNull T> predicate) {
public IsBetween<T> filter(BiPredicate<? super T, ? super T> predicate) {
return filterSupport(predicate, IsBetween::empty, this);
}

@Override
public IsBetween<T> filter(Predicate<? super @NonNull T> predicate) {
public IsBetween<T> filter(Predicate<? super T> predicate) {
return filterSupport(predicate, IsBetween::empty, this);
}

@Override
public <R> IsBetween<R> map(Function<? super @NonNull T, ? extends @NonNull R> mapper1,
Function<? super @NonNull T, ? extends @NonNull R> mapper2) {
public <R> IsBetween<R> map(Function<? super T, ? extends R> mapper1,
Function<? super T, ? extends R> mapper2) {
return mapSupport(mapper1, mapper2, IsBetween::new, IsBetween::empty);
}

@Override
public <R> IsBetween<R> map(Function<? super @NonNull T, ? extends @NonNull R> mapper) {
public <R> IsBetween<R> map(Function<? super T, ? extends R> mapper) {
return map(mapper, mapper);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.function.Function;
import java.util.function.Predicate;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.mybatis.dynamic.sql.AbstractTwoValueCondition;

Expand Down Expand Up @@ -64,23 +63,23 @@ public String operator2() {
}

@Override
public IsBetweenWhenPresent<T> filter(BiPredicate<? super @NonNull T, ? super @NonNull T> predicate) {
public IsBetweenWhenPresent<T> filter(BiPredicate<? super T, ? super T> predicate) {
return filterSupport(predicate, IsBetweenWhenPresent::empty, this);
}

@Override
public IsBetweenWhenPresent<T> filter(Predicate<? super @NonNull T> predicate) {
public IsBetweenWhenPresent<T> filter(Predicate<? super T> predicate) {
return filterSupport(predicate, IsBetweenWhenPresent::empty, this);
}

@Override
public <R> IsBetweenWhenPresent<R> map(Function<? super @NonNull T, ? extends @Nullable R> mapper1,
Function<? super @NonNull T, ? extends @Nullable R> mapper2) {
public <R> IsBetweenWhenPresent<R> map(Function<? super T, ? extends @Nullable R> mapper1,
Function<? super T, ? extends @Nullable R> mapper2) {
return mapSupport(mapper1, mapper2, IsBetweenWhenPresent::of, IsBetweenWhenPresent::empty);
}

@Override
public <R> IsBetweenWhenPresent<R> map(Function<? super @NonNull T, ? extends @Nullable R> mapper) {
public <R> IsBetweenWhenPresent<R> map(Function<? super T, ? extends @Nullable R> mapper) {
return map(mapper, mapper);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.function.Function;
import java.util.function.Predicate;

import org.jspecify.annotations.NonNull;
import org.mybatis.dynamic.sql.AbstractSingleValueCondition;

public class IsEqualTo<T> extends AbstractSingleValueCondition<T>
Expand Down Expand Up @@ -57,12 +56,12 @@ public static <T> IsEqualTo<T> of(T value) {
}

@Override
public IsEqualTo<T> filter(Predicate<? super @NonNull T> predicate) {
public IsEqualTo<T> filter(Predicate<? super T> predicate) {
return filterSupport(predicate, IsEqualTo::empty, this);
}

@Override
public <R> IsEqualTo<R> map(Function<? super @NonNull T, ? extends @NonNull R> mapper) {
public <R> IsEqualTo<R> map(Function<? super T, ? extends R> mapper) {
return mapSupport(mapper, IsEqualTo::new, IsEqualTo::empty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.function.Function;
import java.util.function.Predicate;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.mybatis.dynamic.sql.AbstractSingleValueCondition;

Expand Down Expand Up @@ -62,12 +61,12 @@ public static <T> IsEqualToWhenPresent<T> of(@Nullable T value) {
}

@Override
public IsEqualToWhenPresent<T> filter(Predicate<? super @NonNull T> predicate) {
public IsEqualToWhenPresent<T> filter(Predicate<? super T> predicate) {
return filterSupport(predicate, IsEqualToWhenPresent::empty, this);
}

@Override
public <R> IsEqualToWhenPresent<R> map(Function<? super @NonNull T, ? extends @Nullable R> mapper) {
public <R> IsEqualToWhenPresent<R> map(Function<? super T, ? extends @Nullable R> mapper) {
return mapSupport(mapper, IsEqualToWhenPresent::of, IsEqualToWhenPresent::empty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.function.Function;
import java.util.function.Predicate;

import org.jspecify.annotations.NonNull;
import org.mybatis.dynamic.sql.AbstractSingleValueCondition;

public class IsGreaterThan<T> extends AbstractSingleValueCondition<T>
Expand Down Expand Up @@ -56,12 +55,12 @@ public static <T> IsGreaterThan<T> of(T value) {
}

@Override
public IsGreaterThan<T> filter(Predicate<? super @NonNull T> predicate) {
public IsGreaterThan<T> filter(Predicate<? super T> predicate) {
return filterSupport(predicate, IsGreaterThan::empty, this);
}

@Override
public <R> IsGreaterThan<R> map(Function<? super @NonNull T, ? extends @NonNull R> mapper) {
public <R> IsGreaterThan<R> map(Function<? super T, ? extends R> mapper) {
return mapSupport(mapper, IsGreaterThan::new, IsGreaterThan::empty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.function.Function;
import java.util.function.Predicate;

import org.jspecify.annotations.NonNull;
import org.mybatis.dynamic.sql.AbstractSingleValueCondition;

public class IsGreaterThanOrEqualTo<T> extends AbstractSingleValueCondition<T>
Expand Down Expand Up @@ -56,12 +55,12 @@ public static <T> IsGreaterThanOrEqualTo<T> of(T value) {
}

@Override
public IsGreaterThanOrEqualTo<T> filter(Predicate<? super @NonNull T> predicate) {
public IsGreaterThanOrEqualTo<T> filter(Predicate<? super T> predicate) {
return filterSupport(predicate, IsGreaterThanOrEqualTo::empty, this);
}

@Override
public <R> IsGreaterThanOrEqualTo<R> map(Function<? super @NonNull T, ? extends @NonNull R> mapper) {
public <R> IsGreaterThanOrEqualTo<R> map(Function<? super T, ? extends R> mapper) {
return mapSupport(mapper, IsGreaterThanOrEqualTo::new, IsGreaterThanOrEqualTo::empty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.function.Function;
import java.util.function.Predicate;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.mybatis.dynamic.sql.AbstractSingleValueCondition;

Expand Down Expand Up @@ -62,12 +61,12 @@ public static <T> IsGreaterThanOrEqualToWhenPresent<T> of(@Nullable T value) {
}

@Override
public IsGreaterThanOrEqualToWhenPresent<T> filter(Predicate<? super @NonNull T> predicate) {
public IsGreaterThanOrEqualToWhenPresent<T> filter(Predicate<? super T> predicate) {
return filterSupport(predicate, IsGreaterThanOrEqualToWhenPresent::empty, this);
}

@Override
public <R> IsGreaterThanOrEqualToWhenPresent<R> map(Function<? super @NonNull T, ? extends @Nullable R> mapper) {
public <R> IsGreaterThanOrEqualToWhenPresent<R> map(Function<? super T, ? extends @Nullable R> mapper) {
return mapSupport(mapper, IsGreaterThanOrEqualToWhenPresent::of, IsGreaterThanOrEqualToWhenPresent::empty);
}
}
Loading