FilterNode优化
This commit is contained in:
@@ -9,6 +9,7 @@ import java.io.Serializable;
|
|||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.*;
|
import java.util.function.*;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import org.redkale.convert.ConvertColumn;
|
import org.redkale.convert.ConvertColumn;
|
||||||
import static org.redkale.source.FilterExpress.*;
|
import static org.redkale.source.FilterExpress.*;
|
||||||
import org.redkale.util.*;
|
import org.redkale.util.*;
|
||||||
@@ -79,6 +80,9 @@ public class FilterNode { //FilterNode 不能实现Serializable接口, 否则
|
|||||||
} else {
|
} else {
|
||||||
exp = FilterExpress.IN;
|
exp = FilterExpress.IN;
|
||||||
}
|
}
|
||||||
|
} else if (val instanceof Stream) {
|
||||||
|
val = ((Stream) val).toArray();
|
||||||
|
exp = FilterExpress.IN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.column = col;
|
this.column = col;
|
||||||
@@ -605,6 +609,14 @@ public class FilterNode { //FilterNode 不能实现Serializable接口, 否则
|
|||||||
return and(new FilterNode(column, IN, value));
|
return and(new FilterNode(column, IN, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FilterNode in(String column, Stream stream) {
|
||||||
|
return and(new FilterNode(column, IN, stream == null ? null : (Serializable) stream.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterNode in(String column, Collection collection) {
|
||||||
|
return and(new FilterNode(column, IN, (Serializable) collection));
|
||||||
|
}
|
||||||
|
|
||||||
public <F extends Serializable> FilterNode in(LambdaSupplier<F> func) {
|
public <F extends Serializable> FilterNode in(LambdaSupplier<F> func) {
|
||||||
return and(new FilterNode(LambdaSupplier.readColumn(func), IN, func.get()));
|
return and(new FilterNode(LambdaSupplier.readColumn(func), IN, func.get()));
|
||||||
}
|
}
|
||||||
@@ -617,6 +629,14 @@ public class FilterNode { //FilterNode 不能实现Serializable接口, 否则
|
|||||||
return and(new FilterNode(column, NOT_IN, value));
|
return and(new FilterNode(column, NOT_IN, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FilterNode notIn(String column, Stream stream) {
|
||||||
|
return and(new FilterNode(column, NOT_IN, stream == null ? null : (Serializable) stream.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterNode notIn(String column, Collection collection) {
|
||||||
|
return and(new FilterNode(column, NOT_IN, (Serializable) collection));
|
||||||
|
}
|
||||||
|
|
||||||
public <F extends Serializable> FilterNode notIn(LambdaSupplier<F> func) {
|
public <F extends Serializable> FilterNode notIn(LambdaSupplier<F> func) {
|
||||||
return and(new FilterNode(LambdaSupplier.readColumn(func), NOT_IN, func.get()));
|
return and(new FilterNode(LambdaSupplier.readColumn(func), NOT_IN, func.get()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
package org.redkale.source;
|
package org.redkale.source;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import static org.redkale.source.FilterExpress.*;
|
import static org.redkale.source.FilterExpress.*;
|
||||||
import org.redkale.util.LambdaFunction;
|
import org.redkale.util.LambdaFunction;
|
||||||
import org.redkale.util.LambdaSupplier;
|
import org.redkale.util.LambdaSupplier;
|
||||||
@@ -375,6 +377,14 @@ public final class FilterNodes {
|
|||||||
return new FilterNode(column, IN, value);
|
return new FilterNode(column, IN, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FilterNode in(String column, Stream stream) {
|
||||||
|
return new FilterNode(column, IN, stream == null ? null : (Serializable) stream.toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FilterNode in(String column, Collection collection) {
|
||||||
|
return new FilterNode(column, IN, (Serializable) collection);
|
||||||
|
}
|
||||||
|
|
||||||
public static <F extends Serializable> FilterNode in(LambdaSupplier<F> func) {
|
public static <F extends Serializable> FilterNode in(LambdaSupplier<F> func) {
|
||||||
return new FilterNode(LambdaSupplier.readColumn(func), IN, func.get());
|
return new FilterNode(LambdaSupplier.readColumn(func), IN, func.get());
|
||||||
}
|
}
|
||||||
@@ -387,6 +397,14 @@ public final class FilterNodes {
|
|||||||
return new FilterNode(column, NOT_IN, value);
|
return new FilterNode(column, NOT_IN, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FilterNode notIn(String column, Stream stream) {
|
||||||
|
return new FilterNode(column, NOT_IN, stream == null ? null : (Serializable) stream.toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FilterNode notIn(String column, Collection collection) {
|
||||||
|
return new FilterNode(column, NOT_IN, (Serializable) collection);
|
||||||
|
}
|
||||||
|
|
||||||
public static <F extends Serializable> FilterNode notIn(LambdaSupplier<F> func) {
|
public static <F extends Serializable> FilterNode notIn(LambdaSupplier<F> func) {
|
||||||
return new FilterNode(LambdaSupplier.readColumn(func), NOT_IN, func.get());
|
return new FilterNode(LambdaSupplier.readColumn(func), NOT_IN, func.get());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user