Skip to content

Commit b5189a8

Browse files
authored
Merge pull request #548 from jeffgbutler/remove-deprecated-code
Remove Deprecated Code
2 parents 045460a + c33e78f commit b5189a8

25 files changed

+62
-1863
lines changed

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

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.util.Collection;
1919
import java.util.Objects;
20-
import java.util.function.BiFunction;
2120
import java.util.function.Function;
2221
import java.util.function.Predicate;
2322
import java.util.function.Supplier;
@@ -27,32 +26,8 @@
2726
public abstract class AbstractListValueCondition<T> implements VisitableCondition<T> {
2827
protected final Collection<T> values;
2928

30-
/**
31-
* Callback to execute when the list is empty.
32-
*
33-
* @deprecated in favor of the statement configuration functions
34-
*/
35-
@Deprecated
36-
protected final Callback emptyCallback;
37-
3829
protected AbstractListValueCondition(Collection<T> values) {
39-
this(values, () -> { });
40-
}
41-
42-
/**
43-
* Construct a new condition with a callback.
44-
*
45-
* @param values
46-
* values
47-
* @param emptyCallback
48-
* empty callback
49-
*
50-
* @deprecated in favor of the statement configuration functions
51-
*/
52-
@Deprecated
53-
protected AbstractListValueCondition(Collection<T> values, Callback emptyCallback) {
5430
this.values = Objects.requireNonNull(values);
55-
this.emptyCallback = Objects.requireNonNull(emptyCallback);
5631
}
5732

5833
public final <R> Stream<R> mapValues(Function<T, R> mapper) {
@@ -64,11 +39,6 @@ public boolean shouldRender() {
6439
return !values.isEmpty();
6540
}
6641

67-
@Override
68-
public void renderingSkipped() {
69-
emptyCallback.call();
70-
}
71-
7242
@Override
7343
public <R> R accept(ConditionVisitor<T, R> visitor) {
7444
return visitor.visit(this);
@@ -85,19 +55,19 @@ private Collection<T> applyFilter(Predicate<? super T> predicate) {
8555
}
8656

8757
protected <S extends AbstractListValueCondition<T>> S filterSupport(Predicate<? super T> predicate,
88-
BiFunction<Collection<T>, Callback, S> constructor, S self, Supplier<S> emptySupplier) {
58+
Function<Collection<T>, S> constructor, S self, Supplier<S> emptySupplier) {
8959
if (shouldRender()) {
9060
Collection<T> filtered = applyFilter(predicate);
91-
return filtered.isEmpty() ? emptySupplier.get() : constructor.apply(filtered, emptyCallback);
61+
return filtered.isEmpty() ? emptySupplier.get() : constructor.apply(filtered);
9262
} else {
9363
return self;
9464
}
9565
}
9666

9767
protected <R, S extends AbstractListValueCondition<R>> S mapSupport(Function<? super T, ? extends R> mapper,
98-
BiFunction<Collection<R>, Callback, S> constructor, Supplier<S> emptySupplier) {
68+
Function<Collection<R>, S> constructor, Supplier<S> emptySupplier) {
9969
if (shouldRender()) {
100-
return constructor.apply(applyMapper(mapper), emptyCallback);
70+
return constructor.apply(applyMapper(mapper));
10171
} else {
10272
return emptySupplier.get();
10373
}
@@ -115,18 +85,5 @@ protected <R, S extends AbstractListValueCondition<R>> S mapSupport(Function<? s
11585
*/
11686
public abstract AbstractListValueCondition<T> filter(Predicate<? super T> predicate);
11787

118-
/**
119-
* Specifies a callback function to be called if the value list is empty when rendered.
120-
*
121-
* @param callback
122-
* a callback function - typically throws an exception to block the statement from executing
123-
*
124-
* @return this condition
125-
*
126-
* @deprecated in favor of the statement configuration functions
127-
*/
128-
@Deprecated
129-
public abstract AbstractListValueCondition<T> withListEmptyCallback(Callback callback);
130-
13188
public abstract String renderCondition(String columnName, Stream<String> placeholders);
13289
}

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

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/main/java/org/mybatis/dynamic/sql/insert/render/DefaultInsertStatementProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public class DefaultInsertStatementProvider<T> implements InsertStatementProvide
2424
// need to keep both row and record for now so we don't break
2525
// old code. The MyBatis reflection utilities don't handle
2626
// the case where the attribute name is different from the getter.
27+
//
28+
// MyBatis Generator version 1.4.1 (March 8, 2022) changed to use "row" instead of "record".
29+
// Target March 2023 for removing "record" from MyBatis Dynamic SQL.
2730
private final T record;
2831
private final T row;
2932

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

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
import java.util.Arrays;
2121
import java.util.Collection;
2222
import java.util.Collections;
23-
import java.util.function.BiFunction;
2423
import java.util.function.Function;
2524
import java.util.function.Predicate;
2625
import java.util.stream.Collectors;
2726
import java.util.stream.Stream;
2827

2928
import org.mybatis.dynamic.sql.AbstractListValueCondition;
30-
import org.mybatis.dynamic.sql.Callback;
3129

3230
public class IsIn<T> extends AbstractListValueCondition<T> {
3331
private static final IsIn<?> EMPTY = new IsIn<>(Collections.emptyList());
@@ -38,62 +36,19 @@ public static <T> IsIn<T> empty() {
3836
return t;
3937
}
4038

41-
/**
42-
* Build an empty condition.
43-
*
44-
* @return a new empty condition
45-
*
46-
* @deprecated in favor of the statement configuration functions
47-
*/
48-
@Deprecated
49-
private <S> IsIn<S> emptyWithCallBack() {
50-
return new IsIn<>(Collections.emptyList(), emptyCallback);
51-
}
52-
5339
protected IsIn(Collection<T> values) {
5440
super(values);
5541
}
5642

57-
/**
58-
* Build a new condition with a callback.
59-
*
60-
* @param values
61-
* values
62-
* @param emptyCallback
63-
* empty callback
64-
*
65-
* @deprecated in favor of the statement configuration functions
66-
*/
67-
@Deprecated
68-
protected IsIn(Collection<T> values, Callback emptyCallback) {
69-
super(values, emptyCallback);
70-
}
71-
7243
@Override
7344
public String renderCondition(String columnName, Stream<String> placeholders) {
7445
return spaceAfter(columnName)
7546
+ placeholders.collect(Collectors.joining(",", "in (", ")")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
7647
}
7748

78-
/**
79-
* Build a new condition with a callback.
80-
*
81-
* @param callback
82-
* a callback function - typically throws an exception to block the statement from executing
83-
*
84-
* @return this condition
85-
*
86-
* @deprecated in favor of the statement configuration functions
87-
*/
88-
@Deprecated
89-
@Override
90-
public IsIn<T> withListEmptyCallback(Callback callback) {
91-
return new IsIn<>(values, callback);
92-
}
93-
9449
@Override
9550
public IsIn<T> filter(Predicate<? super T> predicate) {
96-
return filterSupport(predicate, IsIn::new, this, this::emptyWithCallBack);
51+
return filterSupport(predicate, IsIn::new, this, IsIn::empty);
9752
}
9853

9954
/**
@@ -106,8 +61,8 @@ public IsIn<T> filter(Predicate<? super T> predicate) {
10661
* that will not render.
10762
*/
10863
public <R> IsIn<R> map(Function<? super T, ? extends R> mapper) {
109-
BiFunction<Collection<R>, Callback, IsIn<R>> constructor = IsIn::new;
110-
return mapSupport(mapper, constructor, this::emptyWithCallBack);
64+
Function<Collection<R>, IsIn<R>> constructor = IsIn::new;
65+
return mapSupport(mapper, constructor, IsIn::empty);
11166
}
11267

11368
@SafeVarargs

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

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.stream.Stream;
2525

2626
import org.mybatis.dynamic.sql.AbstractListValueCondition;
27-
import org.mybatis.dynamic.sql.Callback;
2827
import org.mybatis.dynamic.sql.util.StringUtilities;
2928

3029
public class IsInCaseInsensitive extends AbstractListValueCondition<String> {
@@ -34,63 +33,20 @@ public static IsInCaseInsensitive empty() {
3433
return EMPTY;
3534
}
3635

37-
/**
38-
* Build an empty condition.
39-
*
40-
* @return a new empty condition
41-
*
42-
* @deprecated in favor of the statement configuration functions
43-
*/
44-
@Deprecated
45-
private IsInCaseInsensitive emptyWithCallback() {
46-
return new IsInCaseInsensitive(Collections.emptyList(), emptyCallback);
47-
}
48-
4936
protected IsInCaseInsensitive(Collection<String> values) {
5037
super(values);
5138
}
5239

53-
/**
54-
* Build a new instance with a callback.
55-
*
56-
* @param values
57-
* values
58-
* @param emptyCallback
59-
* empty callback
60-
*
61-
* @deprecated in favor of the statement configuration functions
62-
*/
63-
@Deprecated
64-
protected IsInCaseInsensitive(Collection<String> values, Callback emptyCallback) {
65-
super(values, emptyCallback);
66-
}
67-
6840
@Override
6941
public String renderCondition(String columnName, Stream<String> placeholders) {
7042
return "upper(" + columnName + ") " //$NON-NLS-1$ //$NON-NLS-2$
7143
+ placeholders.collect(
7244
Collectors.joining(",", "in (", ")")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
7345
}
7446

75-
/**
76-
* Build a new instance with a callback.
77-
*
78-
* @param callback
79-
* a callback function - typically throws an exception to block the statement from executing
80-
*
81-
* @return this condition
82-
*
83-
* @deprecated in favor of the statement configuration functions
84-
*/
85-
@Deprecated
86-
@Override
87-
public IsInCaseInsensitive withListEmptyCallback(Callback callback) {
88-
return new IsInCaseInsensitive(values, callback);
89-
}
90-
9147
@Override
9248
public IsInCaseInsensitive filter(Predicate<? super String> predicate) {
93-
return filterSupport(predicate, IsInCaseInsensitive::new, this, this::emptyWithCallback);
49+
return filterSupport(predicate, IsInCaseInsensitive::new, this, IsInCaseInsensitive::empty);
9450
}
9551

9652
/**
@@ -102,7 +58,7 @@ public IsInCaseInsensitive filter(Predicate<? super String> predicate) {
10258
* that will not render.
10359
*/
10460
public IsInCaseInsensitive map(UnaryOperator<String> mapper) {
105-
return mapSupport(mapper, IsInCaseInsensitive::new, this::emptyWithCallback);
61+
return mapSupport(mapper, IsInCaseInsensitive::new, IsInCaseInsensitive::empty);
10662
}
10763

10864
public static IsInCaseInsensitive of(String... values) {

0 commit comments

Comments
 (0)