mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
package cn.hutool.db.dialect.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
@@ -17,11 +10,11 @@ import cn.hutool.db.Page;
|
||||
import cn.hutool.db.StatementUtil;
|
||||
import cn.hutool.db.dialect.Dialect;
|
||||
import cn.hutool.db.dialect.DialectName;
|
||||
import cn.hutool.db.sql.Condition;
|
||||
import cn.hutool.db.sql.LogicalOperator;
|
||||
import cn.hutool.db.sql.Query;
|
||||
import cn.hutool.db.sql.SqlBuilder;
|
||||
import cn.hutool.db.sql.Wrapper;
|
||||
import cn.hutool.db.sql.*;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* ANSI SQL 方言
|
||||
|
@@ -193,12 +193,9 @@ public abstract class AbstractDSFactory extends DSFactory {
|
||||
return false;
|
||||
}
|
||||
if (setting == null) {
|
||||
if (other.setting != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!setting.equals(other.setting)) {
|
||||
return false;
|
||||
return other.setting == null;
|
||||
} else {
|
||||
return setting.equals(other.setting);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ public class GlobalDSFactory {
|
||||
private static volatile DSFactory factory;
|
||||
private static Object lock = new Object();
|
||||
|
||||
/**
|
||||
/*
|
||||
* 设置在JVM关闭时关闭所有数据库连接
|
||||
*/
|
||||
static {
|
||||
|
@@ -28,5 +28,5 @@ public interface RsHandler<T> extends Serializable{
|
||||
* @return 处理后生成的对象
|
||||
* @throws SQLException SQL异常
|
||||
*/
|
||||
public T handle(ResultSet rs) throws SQLException;
|
||||
T handle(ResultSet rs) throws SQLException;
|
||||
}
|
||||
|
@@ -10,12 +10,12 @@ import java.util.StringTokenizer;
|
||||
* @author looly
|
||||
*/
|
||||
public class SqlFormatter {
|
||||
private static final Set<String> BEGIN_CLAUSES = new HashSet<String>();
|
||||
private static final Set<String> END_CLAUSES = new HashSet<String>();
|
||||
private static final Set<String> LOGICAL = new HashSet<String>();
|
||||
private static final Set<String> QUANTIFIERS = new HashSet<String>();
|
||||
private static final Set<String> DML = new HashSet<String>();
|
||||
private static final Set<String> MISC = new HashSet<String>();
|
||||
private static final Set<String> BEGIN_CLAUSES = new HashSet<>();
|
||||
private static final Set<String> END_CLAUSES = new HashSet<>();
|
||||
private static final Set<String> LOGICAL = new HashSet<>();
|
||||
private static final Set<String> QUANTIFIERS = new HashSet<>();
|
||||
private static final Set<String> DML = new HashSet<>();
|
||||
private static final Set<String> MISC = new HashSet<>();
|
||||
|
||||
static {
|
||||
BEGIN_CLAUSES.add("left");
|
||||
@@ -31,7 +31,6 @@ public class SqlFormatter {
|
||||
END_CLAUSES.add("join");
|
||||
END_CLAUSES.add("from");
|
||||
END_CLAUSES.add("by");
|
||||
END_CLAUSES.add("join");
|
||||
END_CLAUSES.add("into");
|
||||
END_CLAUSES.add("union");
|
||||
|
||||
@@ -55,8 +54,8 @@ public class SqlFormatter {
|
||||
MISC.add("on");
|
||||
}
|
||||
|
||||
private static String indentString = " ";
|
||||
private static String initial = "\n ";
|
||||
private static final String indentString = " ";
|
||||
private static final String initial = "\n ";
|
||||
|
||||
public static String format(String source) {
|
||||
return new FormatProcess(source).perform().trim();
|
||||
@@ -74,8 +73,8 @@ public class SqlFormatter {
|
||||
boolean afterInsert = false;
|
||||
int inFunction = 0;
|
||||
int parensSinceSelect = 0;
|
||||
private LinkedList<Integer> parenCounts = new LinkedList<Integer>();
|
||||
private LinkedList<Boolean> afterByOrFromOrSelects = new LinkedList<Boolean>();
|
||||
private LinkedList<Integer> parenCounts = new LinkedList<>();
|
||||
private LinkedList<Boolean> afterByOrFromOrSelects = new LinkedList<>();
|
||||
|
||||
int indent = 1;
|
||||
|
||||
@@ -141,7 +140,7 @@ public class SqlFormatter {
|
||||
misc();
|
||||
}
|
||||
|
||||
if (!isWhitespace(this.token)) {
|
||||
if (false == isWhitespace(this.token)) {
|
||||
this.lastToken = this.lcToken;
|
||||
}
|
||||
}
|
||||
@@ -313,7 +312,7 @@ public class SqlFormatter {
|
||||
}
|
||||
|
||||
private static boolean isWhitespace(String token) {
|
||||
return " \n\r\f\t".indexOf(token) >= 0;
|
||||
return " \n\r\f\t".contains(token);
|
||||
}
|
||||
|
||||
private void newline() {
|
||||
|
@@ -60,7 +60,7 @@ public enum TransactionLevel {
|
||||
/** 事务级别,对应Connection中的常量值 */
|
||||
private int level;
|
||||
|
||||
private TransactionLevel(int level) {
|
||||
TransactionLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user