This commit is contained in:
@@ -240,7 +240,7 @@ public final class EntityInfo<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityCache<T> getCache() {
|
public EntityCache<T> getCache() {
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ final class FilterBeanNode extends FilterNode {
|
|||||||
|
|
||||||
private long least;
|
private long least;
|
||||||
|
|
||||||
FilterBeanNode(String col, boolean sign, Attribute beanAttr) {
|
protected FilterBeanNode(String col, boolean sign, Attribute beanAttr) {
|
||||||
this.column = col;
|
this.column = col;
|
||||||
this.signand = sign;
|
this.signand = sign;
|
||||||
this.beanAttribute = beanAttr;
|
this.beanAttribute = beanAttr;
|
||||||
@@ -174,7 +174,6 @@ final class FilterBeanNode extends FilterNode {
|
|||||||
this.array = type.isArray();
|
this.array = type.isArray();
|
||||||
this.collection = Collection.class.isAssignableFrom(type);
|
this.collection = Collection.class.isAssignableFrom(type);
|
||||||
this.least = fc == null ? 1L : fc.least();
|
this.least = fc == null ? 1L : fc.least();
|
||||||
this.likefit = fc == null ? true : fc.likefit();
|
|
||||||
this.ignoreCase = fc == null ? true : fc.ignoreCase();
|
this.ignoreCase = fc == null ? true : fc.ignoreCase();
|
||||||
this.number = (type.isPrimitive() && type != boolean.class) || Number.class.isAssignableFrom(type);
|
this.number = (type.isPrimitive() && type != boolean.class) || Number.class.isAssignableFrom(type);
|
||||||
this.string = CharSequence.class.isAssignableFrom(type);
|
this.string = CharSequence.class.isAssignableFrom(type);
|
||||||
|
|||||||
@@ -33,13 +33,6 @@ public @interface FilterColumn {
|
|||||||
*/
|
*/
|
||||||
long least() default 1;
|
long least() default 1;
|
||||||
|
|
||||||
/**
|
|
||||||
* 当express="like" 是否把非空值首尾加上%
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean likefit() default true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LIKE、NOT LIKE时是否区分大小写
|
* LIKE、NOT LIKE时是否区分大小写
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -37,20 +37,14 @@ public class FilterNode {
|
|||||||
|
|
||||||
protected FilterExpress express;
|
protected FilterExpress express;
|
||||||
|
|
||||||
protected boolean likefit = true;
|
|
||||||
|
|
||||||
protected FilterNode[] nodes;
|
protected FilterNode[] nodes;
|
||||||
|
|
||||||
private Serializable value;
|
private Serializable value;
|
||||||
|
|
||||||
public FilterNode() {
|
protected FilterNode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterNode(String col, FilterExpress exp, Serializable val) {
|
protected FilterNode(String col, FilterExpress exp, Serializable val) {
|
||||||
this(col, exp, true, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
FilterNode(String col, FilterExpress exp, boolean likefit, Serializable val) {
|
|
||||||
Objects.requireNonNull(col);
|
Objects.requireNonNull(col);
|
||||||
if (exp == null) {
|
if (exp == null) {
|
||||||
if (val instanceof Range) {
|
if (val instanceof Range) {
|
||||||
@@ -65,7 +59,6 @@ public class FilterNode {
|
|||||||
}
|
}
|
||||||
this.column = col;
|
this.column = col;
|
||||||
this.express = exp;
|
this.express = exp;
|
||||||
this.likefit = likefit;
|
|
||||||
this.value = val;
|
this.value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,10 +74,6 @@ public class FilterNode {
|
|||||||
return and(new FilterNode(column, express, value));
|
return and(new FilterNode(column, express, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final FilterNode and(String column, FilterExpress express, boolean likefit, Serializable value) {
|
|
||||||
return and(new FilterNode(column, express, likefit, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public final FilterNode or(FilterNode node) {
|
public final FilterNode or(FilterNode node) {
|
||||||
return any(node, false);
|
return any(node, false);
|
||||||
}
|
}
|
||||||
@@ -97,10 +86,6 @@ public class FilterNode {
|
|||||||
return or(new FilterNode(column, express, value));
|
return or(new FilterNode(column, express, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final FilterNode or(String column, FilterExpress express, boolean likefit, Serializable value) {
|
|
||||||
return or(new FilterNode(column, express, likefit, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final FilterNode any(FilterNode node, boolean sign) {
|
protected final FilterNode any(FilterNode node, boolean sign) {
|
||||||
Objects.requireNonNull(node);
|
Objects.requireNonNull(node);
|
||||||
if (nodes == null) {
|
if (nodes == null) {
|
||||||
@@ -123,12 +108,10 @@ public class FilterNode {
|
|||||||
FilterNode newnode = new FilterNode(this.column, this.express, this.value);
|
FilterNode newnode = new FilterNode(this.column, this.express, this.value);
|
||||||
newnode.signand = this.signand;
|
newnode.signand = this.signand;
|
||||||
newnode.nodes = this.nodes;
|
newnode.nodes = this.nodes;
|
||||||
newnode.likefit = this.likefit;
|
|
||||||
this.nodes = new FilterNode[]{newnode, node};
|
this.nodes = new FilterNode[]{newnode, node};
|
||||||
this.tabalis = null;
|
this.tabalis = null;
|
||||||
this.column = null;
|
this.column = null;
|
||||||
this.express = null;
|
this.express = null;
|
||||||
this.likefit = false;
|
|
||||||
this.signand = sign;
|
this.signand = sign;
|
||||||
this.value = null;
|
this.value = null;
|
||||||
}
|
}
|
||||||
@@ -917,19 +900,19 @@ public class FilterNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected StringBuilder formatValue(Object value) {
|
protected StringBuilder formatValue(Object value) {
|
||||||
return formatValue(likefit, express, value);
|
return formatValue(express, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String formatToString(Object value) {
|
protected static String formatToString(Object value) {
|
||||||
StringBuilder sb = formatValue(true, null, value);
|
StringBuilder sb = formatValue(null, value);
|
||||||
return sb == null ? null : sb.toString();
|
return sb == null ? null : sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StringBuilder formatValue(boolean likefit, FilterExpress express, Object value) {
|
private static StringBuilder formatValue(FilterExpress express, Object value) {
|
||||||
if (value == null) return null;
|
if (value == null) return null;
|
||||||
if (value instanceof Number) return new StringBuilder().append(value);
|
if (value instanceof Number) return new StringBuilder().append(value);
|
||||||
if (value instanceof CharSequence) {
|
if (value instanceof CharSequence) {
|
||||||
if (likefit && (express == LIKE || express == NOTLIKE)) value = "%" + value + '%';
|
if (express == LIKE || express == NOTLIKE) value = "%" + value + '%';
|
||||||
return new StringBuilder().append('\'').append(value.toString().replace("'", "\\'")).append('\'');
|
return new StringBuilder().append('\'').append(value.toString().replace("'", "\\'")).append('\'');
|
||||||
} else if (value instanceof Range) {
|
} else if (value instanceof Range) {
|
||||||
Range range = (Range) value;
|
Range range = (Range) value;
|
||||||
@@ -952,7 +935,7 @@ public class FilterNode {
|
|||||||
if (len == 0) return express == NOTIN ? null : new StringBuilder("(NULL)");
|
if (len == 0) return express == NOTIN ? null : new StringBuilder("(NULL)");
|
||||||
if (len == 1) {
|
if (len == 1) {
|
||||||
Object firstval = Array.get(value, 0);
|
Object firstval = Array.get(value, 0);
|
||||||
if (firstval != null && firstval.getClass().isArray()) return formatValue(likefit, express, firstval);
|
if (firstval != null && firstval.getClass().isArray()) return formatValue(express, firstval);
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append('(');
|
sb.append('(');
|
||||||
|
|||||||
Reference in New Issue
Block a user