forked from plusone/plusone-commons
'StringBuilder' can be replaced with 'String'.
parent
02febda345
commit
aacfac630c
|
@ -26,12 +26,7 @@ public class JdbcSql extends SQL<JdbcSql> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String IN(String col, int length) {
|
private static String IN(String col, int length) {
|
||||||
return new StringBuilder()
|
return col + " IN (" + String.valueOf(buildQuestionsList(length)) + ')';
|
||||||
.append(col)
|
|
||||||
.append(" IN (")
|
|
||||||
.append(buildQuestionsList(length))
|
|
||||||
.append(')')
|
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String NOT_IN(String col, Collection<?> c) {
|
public static String NOT_IN(String col, Collection<?> c) {
|
||||||
|
@ -43,12 +38,7 @@ public class JdbcSql extends SQL<JdbcSql> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String NOT_IN(String col, int length) {
|
private static String NOT_IN(String col, int length) {
|
||||||
return new StringBuilder()
|
return col + " NOT IN (" + String.valueOf(buildQuestionsList(length)) + ')';
|
||||||
.append(col)
|
|
||||||
.append(" NOT IN (")
|
|
||||||
.append(buildQuestionsList(length))
|
|
||||||
.append(')')
|
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static char[] buildQuestionsList(int times) {
|
private static char[] buildQuestionsList(int times) {
|
||||||
|
|
|
@ -26,40 +26,32 @@ public class MyBatisSql extends SQL<MyBatisSql> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String IN(String col, String paramName) {
|
public static String IN(String col, String paramName) {
|
||||||
return new StringBuilder(" ")
|
return " " + col + " IN" + buildQuestionsList(col, paramName);
|
||||||
.append(col)
|
|
||||||
.append(" IN")
|
|
||||||
.append(buildQuestionsList(col, paramName))
|
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String NOT_IN(String col, String paramName) {
|
public static String NOT_IN(String col, String paramName) {
|
||||||
return new StringBuilder()
|
return col + " NOT IN" + buildQuestionsList(col, paramName);
|
||||||
.append(col)
|
|
||||||
.append(" NOT IN")
|
|
||||||
.append(buildQuestionsList(col, paramName))
|
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String buildQuestionsList(String col, String paramName) {
|
private static String buildQuestionsList(String col, String paramName) {
|
||||||
return new StringBuilder()
|
final String format = "<foreach" +
|
||||||
.append("<foreach item=\"")
|
" item=\"%s\"" +
|
||||||
.append(col)
|
" index=\"index\"" +
|
||||||
.append("\" index=\"index\" collection=\"")
|
" collection=\"%s\"" +
|
||||||
.append(paramName)
|
" open=\"(\"" +
|
||||||
.append("\" open=\"(\" separator=\",\" close=\")\">")
|
" separator=\",\"" +
|
||||||
.append("#{")
|
" close=\")\"" +
|
||||||
.append(col)
|
">" +
|
||||||
.append("}</foreach>")
|
"#{%s}" +
|
||||||
.toString();
|
"</foreach>";
|
||||||
|
return String.format(format, col, paramName, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String str = super.toString();
|
|
||||||
if (withScript) {
|
if (withScript) {
|
||||||
str = "<script>\n" + str + "\n</script>";
|
return "<script>\n" + super.toString() + "\n</script>";
|
||||||
}
|
}
|
||||||
return str;
|
return super.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue