Skip to content

Commit d73b31b

Browse files
committed
Define a map template method for two value
1 parent e52fa81 commit d73b31b

File tree

3 files changed

+28
-38
lines changed

3 files changed

+28
-38
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,30 @@ protected <R, S extends AbstractTwoValueCondition<R>> S mapSupport(Function<? su
8888
*/
8989
public abstract AbstractTwoValueCondition<T> filter(Predicate<? super T> predicate);
9090

91+
/**
92+
* If renderable, apply the mappings to the values and return a new condition with the new values. Else return a
93+
* condition that will not render (this).
94+
*
95+
* @param mapper1 a mapping function to apply to the first value, if renderable
96+
* @param mapper2 a mapping function to apply to the second value, if renderable
97+
* @param <R> type of the new condition
98+
* @return a new condition with the result of applying the mappers to the values of this condition,
99+
* if renderable, otherwise a condition that will not render.
100+
*/
101+
public abstract <R> AbstractTwoValueCondition<R> map(Function<? super T, ? extends R> mapper1,
102+
Function<? super T, ? extends R> mapper2);
103+
104+
/**
105+
* If renderable, apply the mapping to both values and return a new condition with the new values. Else return a
106+
* condition that will not render (this).
107+
*
108+
* @param mapper a mapping function to apply to both values, if renderable
109+
* @param <R> type of the new condition
110+
* @return a new condition with the result of applying the mappers to the values of this condition,
111+
* if renderable, otherwise a condition that will not render.
112+
*/
113+
public abstract <R> AbstractTwoValueCondition<R> map(Function<? super T, ? extends R> mapper);
114+
91115
public abstract String operator1();
92116

93117
public abstract String operator2();

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

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,12 @@ public IsBetween<T> filter(Predicate<? super T> predicate) {
7171
return filterSupport(predicate, IsBetween::empty, this);
7272
}
7373

74-
/**
75-
* If renderable, apply the mappings to the values and return a new condition with the new values. Else return a
76-
* condition that will not render (this).
77-
*
78-
* @param mapper1 a mapping function to apply to the first value, if renderable
79-
* @param mapper2 a mapping function to apply to the second value, if renderable
80-
* @param <R> type of the new condition
81-
* @return a new condition with the result of applying the mappers to the values of this condition,
82-
* if renderable, otherwise a condition that will not render.
83-
*/
74+
@Override
8475
public <R> IsBetween<R> map(Function<? super T, ? extends R> mapper1, Function<? super T, ? extends R> mapper2) {
8576
return mapSupport(mapper1, mapper2, IsBetween::new, IsBetween::empty);
8677
}
8778

88-
/**
89-
* If renderable, apply the mapping to both values and return a new condition with the new values. Else return a
90-
* condition that will not render (this).
91-
*
92-
* @param mapper a mapping function to apply to both values, if renderable
93-
* @param <R> type of the new condition
94-
* @return a new condition with the result of applying the mappers to the values of this condition,
95-
* if renderable, otherwise a condition that will not render.
96-
*/
79+
@Override
9780
public <R> IsBetween<R> map(Function<? super T, ? extends R> mapper) {
9881
return map(mapper, mapper);
9982
}

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

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,13 @@ public IsNotBetween<T> filter(Predicate<? super T> predicate) {
7171
return filterSupport(predicate, IsNotBetween::empty, this);
7272
}
7373

74-
/**
75-
* If renderable, apply the mappings to the values and return a new condition with the new values. Else return a
76-
* condition that will not render (this).
77-
*
78-
* @param mapper1 a mapping function to apply to the first value, if renderable
79-
* @param mapper2 a mapping function to apply to the second value, if renderable
80-
* @param <R> type of the new condition
81-
* @return a new condition with the result of applying the mappers to the values of this condition,
82-
* if renderable, otherwise a condition that will not render.
83-
*/
74+
@Override
8475
public <R> IsNotBetween<R> map(Function<? super T, ? extends R> mapper1,
8576
Function<? super T, ? extends R> mapper2) {
8677
return mapSupport(mapper1, mapper2, IsNotBetween::new, IsNotBetween::empty);
8778
}
8879

89-
/**
90-
* If renderable, apply the mapping to both values and return a new condition with the new values. Else return a
91-
* condition that will not render (this).
92-
*
93-
* @param mapper a mapping function to apply to both values, if renderable
94-
* @param <R> type of the new condition
95-
* @return a new condition with the result of applying the mappers to the values of this condition,
96-
* if renderable, otherwise a condition that will not render.
97-
*/
80+
@Override
9881
public <R> IsNotBetween<R> map(Function<? super T, ? extends R> mapper) {
9982
return map(mapper, mapper);
10083
}

0 commit comments

Comments
 (0)