GitHub Viewer
/*Copyright (C) 2020 Tencent. All rights reserved.
This source code is licensed under the Apache License Version 2.0.*/
package apijson;
/**SQL语句,函数名尽量和JDK中相同或类似功能的函数的名称一致
* @author Lemon
*/
public class SQL {
public static final String JOIN = " JOIN ";
public static final String ON = " ON ";
public static final String OR = " OR ";
public static final String AND = " AND ";
public static final String NOT = " NOT ";
public static final String AS = " AS ";
public static final String IS = " IS ";
public static final String NULL = " NULL ";
public static final String IS_NOT = " IS NOT ";
public static final String IS_NULL = " IS NULL ";
public static final String IS_NOT_NULL = " IS NOT NULL ";
//括号必须紧跟函数名! count (...) 报错!
public static final String COUNT = "count";
public static final String SUM = "sum";
public static final String MAX = "max";
public static final String MIN = "min";
public static final String AVG = "avg";
/**
* isNull = true
* @return {@link #isNull(boolean)}
*/
public static String isNull() {
return isNull(true);
}
/**
* @param isNull
* @return {@link #IS} + (isNull ? "" : {@link #NOT}) + {@link #NULL};
*/
public static String isNull(boolean isNull) {
return IS + (isNull ? "" : NOT) + NULL;
}
/**
* isNull = true
* @param s
* @return {@link #isNull(String, boolean)}
*/
public static String isNull(String s) {
return isNull(s, true);
}
/**
* @param s
* @param isNull
* @return s + {@link #isNull(boolean)}
*/
public static String isNull(String s, boolean isNull) {
return s + isNull(isNull);
}
/**
* isEmpty = true
* @param s
* @return {@link #isEmpty(String, boolean)}
*/
public static String isEmpty(String s) {
return isEmpty(s, true);
}
/**
* trim = false
* @param s
* @param isEmpty
* @return {@link #isEmpty(String, boolean, boolean)}
*/
public static String isEmpty(String s, boolean isEmpty) {
return isEmpty(s, isEmpty, false);
}
/**
* nullable = true
* @param s
* @param isEmpty >
//search>
public static boolean isBooleanOrNumber(String type) {
type = StringUtil.toUpperCase(type, true);
return type.isEmpty() || (type.endsWith("INT") && type.endsWith("POINT") == false)
|| type.endsWith("BOOLEAN") || type.endsWith("ENUM")
|| type.endsWith("FLOAT") || type.endsWith("DOUBLE") || type.endsWith("DECIMAL");
}
}