FilterKey更名为FilterColValue

This commit is contained in:
redkale
2023-11-16 09:41:06 +08:00
parent af45c451a3
commit e44afc9208
4 changed files with 31 additions and 31 deletions

View File

@@ -10,8 +10,8 @@ import org.redkale.annotation.ConstructorParameters;
import org.redkale.convert.ConvertColumn; import org.redkale.convert.ConvertColumn;
/** /**
* FilterKey主要用于自身字段间的表达式, a.recordid = a.parentid , a.parentid就需要FilterKey来表示 new FilterKey("parentid") * 主要用于自身字段间的表达式, a.recordid = a.parentid , a.parentid就需要FilterColValue来表示 new FilterColValue("parentid")
* <br> <br>
* 注意该类型不支持表达式FV_XXXBETWEENNOTBETWEENINNOTIN * 注意该类型不支持表达式FV_XXXBETWEENNOTBETWEENINNOTIN
* *
* <p> * <p>
@@ -19,13 +19,13 @@ import org.redkale.convert.ConvertColumn;
* *
* @author zhangjx * @author zhangjx
*/ */
public class FilterKey implements java.io.Serializable { public class FilterColValue implements java.io.Serializable {
@ConvertColumn(index = 1) @ConvertColumn(index = 1)
private final String column; private final String column;
@ConstructorParameters({"column"}) @ConstructorParameters({"column"})
public FilterKey(String column) { public FilterColValue(String column) {
this.column = Objects.requireNonNull(column); this.column = Objects.requireNonNull(column);
} }

View File

@@ -16,7 +16,7 @@ import org.redkale.convert.ConvertColumn;
* *
* @author zhangjx * @author zhangjx
*/ */
public class FilterValue implements java.io.Serializable { public class FilterExpValue implements java.io.Serializable {
@ConvertColumn(index = 1) @ConvertColumn(index = 1)
private Number left; private Number left;
@@ -27,18 +27,18 @@ public class FilterValue implements java.io.Serializable {
@ConvertColumn(index = 3) @ConvertColumn(index = 3)
private Number right; private Number right;
public FilterValue() { public FilterExpValue() {
} }
public FilterValue(Number left, Number right) { public FilterExpValue(Number left, Number right) {
this(left, FilterExpress.EQ, right); this(left, FilterExpress.EQ, right);
} }
public FilterValue(Number left, FilterExpress express) { public FilterExpValue(Number left, FilterExpress express) {
this(left, express, 0); this(left, express, 0);
} }
public FilterValue(Number left, FilterExpress express, Number right) { public FilterExpValue(Number left, FilterExpress express, Number right) {
this.left = left; this.left = left;
this.express = FilterNodes.oldExpress(express); this.express = FilterNodes.oldExpress(express);
this.right = right; this.right = right;
@@ -70,6 +70,6 @@ public class FilterValue implements java.io.Serializable {
@Override @Override
public String toString() { public String toString() {
return FilterValue.class.getSimpleName() + "[left=" + getLeft() + ", express=" + getExpress() + ", right=" + getRight() + "]"; return FilterExpValue.class.getSimpleName() + "[left=" + getLeft() + ", express=" + getExpress() + ", right=" + getRight() + "]";
} }
} }

View File

@@ -709,27 +709,27 @@ public class FilterNode { //FilterNode 不能实现Serializable接口 否则
return and(new FilterNode(LambdaFunction.readColumn(func), NOT_OPAND, value)); return and(new FilterNode(LambdaFunction.readColumn(func), NOT_OPAND, value));
} }
public FilterNode fvmode(String column, FilterValue value) { public FilterNode fvmode(String column, FilterExpValue value) {
return and(new FilterNode(column, FV_MOD, value)); return and(new FilterNode(column, FV_MOD, value));
} }
public <F extends FilterValue> FilterNode fvmode(LambdaSupplier<F> func) { public <F extends FilterExpValue> FilterNode fvmode(LambdaSupplier<F> func) {
return and(new FilterNode(LambdaSupplier.readColumn(func), FV_MOD, func.get())); return and(new FilterNode(LambdaSupplier.readColumn(func), FV_MOD, func.get()));
} }
public <T, F extends FilterValue> FilterNode fvmode(LambdaFunction<T, F> func, F value) { public <T, F extends FilterExpValue> FilterNode fvmode(LambdaFunction<T, F> func, F value) {
return and(new FilterNode(LambdaFunction.readColumn(func), FV_MOD, value)); return and(new FilterNode(LambdaFunction.readColumn(func), FV_MOD, value));
} }
public FilterNode fvdiv(String column, FilterValue value) { public FilterNode fvdiv(String column, FilterExpValue value) {
return and(new FilterNode(column, FV_DIV, value)); return and(new FilterNode(column, FV_DIV, value));
} }
public <F extends FilterValue> FilterNode fvdiv(LambdaSupplier<F> func) { public <F extends FilterExpValue> FilterNode fvdiv(LambdaSupplier<F> func) {
return and(new FilterNode(LambdaSupplier.readColumn(func), FV_DIV, func.get())); return and(new FilterNode(LambdaSupplier.readColumn(func), FV_DIV, func.get()));
} }
public <T, F extends FilterValue> FilterNode fvdiv(LambdaFunction<T, F> func, F value) { public <T, F extends FilterExpValue> FilterNode fvdiv(LambdaFunction<T, F> func, F value) {
return and(new FilterNode(LambdaFunction.readColumn(func), FV_DIV, value)); return and(new FilterNode(LambdaFunction.readColumn(func), FV_DIV, value));
} }
@@ -967,12 +967,12 @@ public class FilterNode { //FilterNode 不能实现Serializable接口 否则
return null; return null;
} }
if (express == FV_MOD || express == FV_DIV) { if (express == FV_MOD || express == FV_DIV) {
FilterValue fv = (FilterValue) val0; FilterExpValue fv = (FilterExpValue) val0;
return new StringBuilder().append(info.getSQLColumn(talis, column)).append(' ').append(express.value()).append(' ').append(fv.getLeft()) return new StringBuilder().append(info.getSQLColumn(talis, column)).append(' ').append(express.value()).append(' ').append(fv.getLeft())
.append(' ').append(fv.getExpress().value()).append(' ').append(fv.getRight()); .append(' ').append(fv.getExpress().value()).append(' ').append(fv.getRight());
} }
final boolean fk = (val0 instanceof FilterKey); final boolean fk = (val0 instanceof FilterColValue);
CharSequence val = fk ? info.getSQLColumn(talis, ((FilterKey) val0).getColumn()) : formatToString(express, info.getSQLValue(column, (Serializable) val0)); CharSequence val = fk ? info.getSQLColumn(talis, ((FilterColValue) val0).getColumn()) : formatToString(express, info.getSQLValue(column, (Serializable) val0));
if (val == null) { if (val == null) {
return null; return null;
} }
@@ -996,7 +996,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口 否则
} else if (express == IG_EQ || express == IG_NOT_EQ || express == IG_LIKE || express == IG_NOT_LIKE) { } else if (express == IG_EQ || express == IG_NOT_EQ || express == IG_LIKE || express == IG_NOT_LIKE) {
sb.append("LOWER(").append(info.getSQLColumn(talis, column)).append(')'); sb.append("LOWER(").append(info.getSQLColumn(talis, column)).append(')');
if (fk) { if (fk) {
val = "LOWER(" + info.getSQLColumn(talis, ((FilterKey) val0).getColumn()) + ')'; val = "LOWER(" + info.getSQLColumn(talis, ((FilterColValue) val0).getColumn()) + ')';
} }
} else { } else {
sb.append(info.getSQLColumn(talis, column)); sb.append(info.getSQLColumn(talis, column));
@@ -1374,10 +1374,10 @@ public class FilterNode { //FilterNode 不能实现Serializable接口 否则
} }
} }
final Serializable val = (Serializable) val0; final Serializable val = (Serializable) val0;
final boolean fk = (val instanceof FilterKey); final boolean fk = (val instanceof FilterColValue);
final Attribute<T, Serializable> fkattr = fk ? cache.getAttribute(((FilterKey) val).getColumn()) : null; final Attribute<T, Serializable> fkattr = fk ? cache.getAttribute(((FilterColValue) val).getColumn()) : null;
if (fk && fkattr == null) { if (fk && fkattr == null) {
throw new SourceException(cache.getType() + " not found column(" + ((FilterKey) val).getColumn() + ")"); throw new SourceException(cache.getType() + " not found column(" + ((FilterColValue) val).getColumn() + ")");
} }
switch (express) { switch (express) {
case EQ: case EQ:
@@ -1598,7 +1598,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口 否则
}; };
case FV_MOD: case FV_MOD:
FilterValue fv0 = (FilterValue) val; FilterExpValue fv0 = (FilterExpValue) val;
switch (fv0.getExpress()) { switch (fv0.getExpress()) {
case EQ: case EQ:
return new Predicate<T>() { return new Predicate<T>() {
@@ -1682,7 +1682,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口 否则
throw new SourceException("(" + fv0 + ")'s express illegal, must be =, !=, <, >, <=, >="); throw new SourceException("(" + fv0 + ")'s express illegal, must be =, !=, <, >, <=, >=");
} }
case FV_DIV: case FV_DIV:
FilterValue fv1 = (FilterValue) val; FilterExpValue fv1 = (FilterExpValue) val;
switch (fv1.getExpress()) { switch (fv1.getExpress()) {
case EQ: case EQ:
return new Predicate<T>() { return new Predicate<T>() {

View File

@@ -479,27 +479,27 @@ public final class FilterNodes {
return new FilterNode(LambdaFunction.readColumn(func), NOT_OPAND, value); return new FilterNode(LambdaFunction.readColumn(func), NOT_OPAND, value);
} }
public static FilterNode fvmode(String column, FilterValue value) { public static FilterNode fvmode(String column, FilterExpValue value) {
return new FilterNode(column, FV_MOD, value); return new FilterNode(column, FV_MOD, value);
} }
public static <F extends FilterValue> FilterNode fvmode(LambdaSupplier<F> func) { public static <F extends FilterExpValue> FilterNode fvmode(LambdaSupplier<F> func) {
return new FilterNode(LambdaSupplier.readColumn(func), FV_MOD, func.get()); return new FilterNode(LambdaSupplier.readColumn(func), FV_MOD, func.get());
} }
public static <T, F extends FilterValue> FilterNode fvmode(LambdaFunction<T, F> func, F value) { public static <T, F extends FilterExpValue> FilterNode fvmode(LambdaFunction<T, F> func, F value) {
return new FilterNode(LambdaFunction.readColumn(func), FV_MOD, value); return new FilterNode(LambdaFunction.readColumn(func), FV_MOD, value);
} }
public static FilterNode fvdiv(String column, FilterValue value) { public static FilterNode fvdiv(String column, FilterExpValue value) {
return new FilterNode(column, FV_DIV, value); return new FilterNode(column, FV_DIV, value);
} }
public static <F extends FilterValue> FilterNode fvdiv(LambdaSupplier<F> func) { public static <F extends FilterExpValue> FilterNode fvdiv(LambdaSupplier<F> func) {
return new FilterNode(LambdaSupplier.readColumn(func), FV_DIV, func.get()); return new FilterNode(LambdaSupplier.readColumn(func), FV_DIV, func.get());
} }
public static <T, F extends FilterValue> FilterNode fvdiv(LambdaFunction<T, F> func, F value) { public static <T, F extends FilterExpValue> FilterNode fvdiv(LambdaFunction<T, F> func, F value) {
return new FilterNode(LambdaFunction.readColumn(func), FV_DIV, value); return new FilterNode(LambdaFunction.readColumn(func), FV_DIV, value);
} }