Skip to content

Commit e31f68f

Browse files
committed
Deprecate the "empty list" methods
The new statement configuration functionality is better and more flexible
1 parent cd009d6 commit e31f68f

File tree

5 files changed

+89
-1
lines changed

5 files changed

+89
-1
lines changed

src/main/java/org/mybatis/dynamic/sql/AbstractListValueCondition.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,12 +26,23 @@
2626

2727
public abstract class AbstractListValueCondition<T> implements VisitableCondition<T> {
2828
protected final Collection<T> values;
29+
30+
/**
31+
* @deprecated in favor of the statement configuration functions
32+
*/
33+
@Deprecated
2934
protected final Callback emptyCallback;
3035

3136
protected AbstractListValueCondition(Collection<T> values) {
3237
this(values, () -> { });
3338
}
3439

40+
/**
41+
* @deprecated in favor of the statement configuration functions
42+
* @param values values
43+
* @param emptyCallback empty callback
44+
*/
45+
@Deprecated
3546
protected AbstractListValueCondition(Collection<T> values, Callback emptyCallback) {
3647
this.values = Objects.requireNonNull(values);
3748
this.emptyCallback = Objects.requireNonNull(emptyCallback);
@@ -96,6 +107,14 @@ protected <R, S extends AbstractListValueCondition<R>> S mapSupport(Function<? s
96107
*/
97108
public abstract AbstractListValueCondition<T> filter(Predicate<? super T> predicate);
98109

110+
/**
111+
* Specifies a callback function to be called if the value list is empty when rendered.
112+
*
113+
* @deprecated in favor of the statement configuration functions
114+
* @param callback a callback function - typically throws an exception to block the statement from executing
115+
* @return this condition
116+
*/
117+
@Deprecated
99118
public abstract AbstractListValueCondition<T> withListEmptyCallback(Callback callback);
100119

101120
public abstract String renderCondition(String columnName, Stream<String> placeholders);

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public static <T> IsIn<T> empty() {
3838
return t;
3939
}
4040

41+
/**
42+
* @deprecated in favor of the statement configuration functions
43+
* @return a new empty condition
44+
*/
45+
@Deprecated
4146
private <S> IsIn<S> emptyWithCallBack() {
4247
return new IsIn<>(Collections.emptyList(), emptyCallback);
4348
}
@@ -46,6 +51,12 @@ protected IsIn(Collection<T> values) {
4651
super(values);
4752
}
4853

54+
/**
55+
* @deprecated in favor of the statement configuration functions
56+
* @param values values
57+
* @param emptyCallback empty callback
58+
*/
59+
@Deprecated
4960
protected IsIn(Collection<T> values, Callback emptyCallback) {
5061
super(values, emptyCallback);
5162
}
@@ -56,6 +67,12 @@ public String renderCondition(String columnName, Stream<String> placeholders) {
5667
+ placeholders.collect(Collectors.joining(",", "in (", ")")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
5768
}
5869

70+
/**
71+
* @deprecated in favor of the statement configuration functions
72+
* @param callback a callback function - typically throws an exception to block the statement from executing
73+
* @return this condition
74+
*/
75+
@Deprecated
5976
@Override
6077
public IsIn<T> withListEmptyCallback(Callback callback) {
6178
return new IsIn<>(values, callback);

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public static IsInCaseInsensitive empty() {
3434
return EMPTY;
3535
}
3636

37+
/**
38+
* @deprecated in favor of the statement configuration functions
39+
* @return a new empty condition
40+
*/
41+
@Deprecated
3742
private IsInCaseInsensitive emptyWithCallback() {
3843
return new IsInCaseInsensitive(Collections.emptyList(), emptyCallback);
3944
}
@@ -42,6 +47,12 @@ protected IsInCaseInsensitive(Collection<String> values) {
4247
super(values);
4348
}
4449

50+
/**
51+
* @deprecated in favor of the statement configuration functions
52+
* @param values values
53+
* @param emptyCallback empty callback
54+
*/
55+
@Deprecated
4556
protected IsInCaseInsensitive(Collection<String> values, Callback emptyCallback) {
4657
super(values, emptyCallback);
4758
}
@@ -53,6 +64,12 @@ public String renderCondition(String columnName, Stream<String> placeholders) {
5364
Collectors.joining(",", "in (", ")")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
5465
}
5566

67+
/**
68+
* @deprecated in favor of the statement configuration functions
69+
* @param callback a callback function - typically throws an exception to block the statement from executing
70+
* @return this condition
71+
*/
72+
@Deprecated
5673
@Override
5774
public IsInCaseInsensitive withListEmptyCallback(Callback callback) {
5875
return new IsInCaseInsensitive(values, callback);

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public static <T> IsNotIn<T> empty() {
3838
return t;
3939
}
4040

41+
/**
42+
* @deprecated in favor of the statement configuration functions
43+
* @return a new empty condition
44+
*/
45+
@Deprecated
4146
private <S> IsNotIn<S> emptyWithCallback() {
4247
return new IsNotIn<>(Collections.emptyList(), emptyCallback);
4348
}
@@ -46,6 +51,12 @@ protected IsNotIn(Collection<T> values) {
4651
super(values);
4752
}
4853

54+
/**
55+
* @deprecated in favor of the statement configuration functions
56+
* @param values values
57+
* @param emptyCallback empty callback
58+
*/
59+
@Deprecated
4960
protected IsNotIn(Collection<T> values, Callback emptyCallback) {
5061
super(values, emptyCallback);
5162
}
@@ -57,6 +68,13 @@ public String renderCondition(String columnName, Stream<String> placeholders) {
5768
Collectors.joining(",", "not in (", ")")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
5869
}
5970

71+
/**
72+
*
73+
* @deprecated in favor of the statement configuration functions
74+
* @param callback a callback function - typically throws an exception to block the statement from executing
75+
* @return this condition
76+
*/
77+
@Deprecated
6078
@Override
6179
public IsNotIn<T> withListEmptyCallback(Callback callback) {
6280
return new IsNotIn<>(values, callback);

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public static IsNotInCaseInsensitive empty() {
3434
return EMPTY;
3535
}
3636

37+
/**
38+
* @deprecated in favor of the statement configuration functions
39+
* @return a new empty condition
40+
*/
41+
@Deprecated
3742
private IsNotInCaseInsensitive emptyWithCallback() {
3843
return new IsNotInCaseInsensitive(Collections.emptyList(), emptyCallback);
3944
}
@@ -42,6 +47,12 @@ protected IsNotInCaseInsensitive(Collection<String> values) {
4247
super(values);
4348
}
4449

50+
/**
51+
* @deprecated in favor of the statement configuration functions
52+
* @param values values
53+
* @param emptyCallback empty callback
54+
*/
55+
@Deprecated
4556
protected IsNotInCaseInsensitive(Collection<String> values, Callback emptyCallback) {
4657
super(values, emptyCallback);
4758
}
@@ -53,6 +64,12 @@ public String renderCondition(String columnName, Stream<String> placeholders) {
5364
Collectors.joining(",", "not in (", ")")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
5465
}
5566

67+
/**
68+
* @deprecated in favor of the statement configuration functions
69+
* @param callback a callback function - typically throws an exception to block the statement from executing
70+
* @return this condition
71+
*/
72+
@Deprecated
5673
@Override
5774
public IsNotInCaseInsensitive withListEmptyCallback(Callback callback) {
5875
return new IsNotInCaseInsensitive(values, callback);

0 commit comments

Comments
 (0)