Unverified 提交 705e592e authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #863 from igor-suhorukov/master

Polish: use isEmpty() to check whether the collection is empty or not.
......@@ -548,7 +548,7 @@ public class Parser {
}
private DbException getSyntaxError() {
if (expectedList == null || expectedList.size() == 0) {
if (expectedList == null || expectedList.isEmpty()) {
return DbException.getSyntaxError(sqlCommand, parseIndex);
}
StatementBuilder buff = new StatementBuilder();
......@@ -3023,7 +3023,7 @@ public class Parser {
// this can occur when parsing expressions only (for
// example check constraints)
throw getSyntaxError();
} else if (parameters.size() > 0) {
} else if (!parameters.isEmpty()) {
throw DbException
.get(ErrorCode.CANNOT_MIX_INDEXED_AND_UNINDEXED_PARAMS);
}
......@@ -4725,7 +4725,7 @@ public class Parser {
int scale, displaySize;
Column column;
String columnName = "C" + (i + 1);
if (rows.size() == 0) {
if (rows.isEmpty()) {
if (type == Value.UNKNOWN) {
type = Value.STRING;
}
......
......@@ -119,7 +119,7 @@ public class CreateTable extends SchemaCommand {
}
if (asQuery != null) {
asQuery.prepare();
if (data.columns.size() == 0) {
if (data.columns.isEmpty()) {
generateColumnsFromQuery();
} else if (data.columns.size() != asQuery.getColumnCount()) {
throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
......
......@@ -98,7 +98,7 @@ public class CreateView extends SchemaCommand {
querySQL = selectSQL;
} else {
ArrayList<Parameter> params = select.getParameters();
if (params != null && params.size() > 0) {
if (params != null && !params.isEmpty()) {
throw DbException.getUnsupportedException("parameters in views");
}
querySQL = select.getPlanSQL();
......
......@@ -77,7 +77,7 @@ public class DropTable extends SchemaCommand {
if (dropAction == ConstraintActionType.RESTRICT) {
StatementBuilder buff = new StatementBuilder();
CopyOnWriteArrayList<TableView> dependentViews = table.getDependentViews();
if (dependentViews != null && dependentViews.size() > 0) {
if (dependentViews != null && !dependentViews.isEmpty()) {
for (TableView v : dependentViews) {
buff.appendExceptFirst(", ");
buff.append(v.getName());
......@@ -86,7 +86,7 @@ public class DropTable extends SchemaCommand {
if (session.getDatabase()
.getSettings().standardDropTableRestrict) {
final List<Constraint> constraints = table.getConstraints();
if (constraints != null && constraints.size() > 0) {
if (constraints != null && !constraints.isEmpty()) {
for (Constraint c : constraints) {
if (c.getTable() != table) {
buff.appendExceptFirst(", ");
......
......@@ -243,7 +243,7 @@ public class Insert extends Prepared implements ResultTarget {
if (sortedInsertMode) {
buff.append("SORTED ");
}
if (list.size() > 0) {
if (!list.isEmpty()) {
buff.append("VALUES ");
int row = 0;
if (list.size() > 1) {
......@@ -274,14 +274,14 @@ public class Insert extends Prepared implements ResultTarget {
@Override
public void prepare() {
if (columns == null) {
if (list.size() > 0 && list.get(0).length == 0) {
if (!list.isEmpty() && list.get(0).length == 0) {
// special case where table is used as a sequence
columns = new Column[0];
} else {
columns = table.getColumns();
}
}
if (list.size() > 0) {
if (!list.isEmpty()) {
for (Expression[] expr : list) {
if (expr.length != columns.length) {
throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
......
......@@ -84,7 +84,7 @@ public class Merge extends Prepared {
session.getUser().checkRight(targetTable, Right.INSERT);
session.getUser().checkRight(targetTable, Right.UPDATE);
setCurrentRowNumber(0);
if (valuesExpressionList.size() > 0) {
if (!valuesExpressionList.isEmpty()) {
// process values in list
count = 0;
for (int x = 0, size = valuesExpressionList.size(); x < size; x++) {
......@@ -221,7 +221,7 @@ public class Merge extends Prepared {
buff.append(')');
}
buff.append('\n');
if (valuesExpressionList.size() > 0) {
if (!valuesExpressionList.isEmpty()) {
buff.append("VALUES ");
int row = 0;
for (Expression[] expr : valuesExpressionList) {
......@@ -249,14 +249,14 @@ public class Merge extends Prepared {
@Override
public void prepare() {
if (columns == null) {
if (valuesExpressionList.size() > 0 && valuesExpressionList.get(0).length == 0) {
if (!valuesExpressionList.isEmpty() && valuesExpressionList.get(0).length == 0) {
// special case where table is used as a sequence
columns = new Column[0];
} else {
columns = targetTable.getColumns();
}
}
if (valuesExpressionList.size() > 0) {
if (!valuesExpressionList.isEmpty()) {
for (Expression[] expr : valuesExpressionList) {
if (expr.length != columns.length) {
throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
......
......@@ -315,7 +315,7 @@ public class MergeUsing extends Prepared {
buff.append(')');
}
buff.append('\n');
if (valuesExpressionList.size() > 0) {
if (!valuesExpressionList.isEmpty()) {
buff.append("VALUES ");
int row = 0;
for (Expression[] expr : valuesExpressionList) {
......@@ -376,7 +376,7 @@ public class MergeUsing extends Prepared {
onCondition.createIndexConditions(session, targetTableFilter);
if (columns == null) {
if (valuesExpressionList.size() > 0
if (!valuesExpressionList.isEmpty()
&& valuesExpressionList.get(0).length == 0) {
// special case where table is used as a sequence
columns = new Column[0];
......@@ -384,7 +384,7 @@ public class MergeUsing extends Prepared {
columns = targetTable.getColumns();
}
}
if (valuesExpressionList.size() > 0) {
if (!valuesExpressionList.isEmpty()) {
for (Expression[] expr : valuesExpressionList) {
if (expr.length != columns.length) {
throw DbException
......
......@@ -82,7 +82,7 @@ public class Replace extends Prepared {
session.getUser().checkRight(table, Right.INSERT);
session.getUser().checkRight(table, Right.UPDATE);
setCurrentRowNumber(0);
if (list.size() > 0) {
if (!list.isEmpty()) {
count = 0;
for (int x = 0, size = list.size(); x < size; x++) {
setCurrentRowNumber(x + 1);
......@@ -208,7 +208,7 @@ public class Replace extends Prepared {
}
buff.append(')');
buff.append('\n');
if (list.size() > 0) {
if (!list.isEmpty()) {
buff.append("VALUES ");
int row = 0;
for (Expression[] expr : list) {
......@@ -236,14 +236,14 @@ public class Replace extends Prepared {
@Override
public void prepare() {
if (columns == null) {
if (list.size() > 0 && list.get(0).length == 0) {
if (!list.isEmpty() && list.get(0).length == 0) {
// special case where table is used as a sequence
columns = new Column[0];
} else {
columns = table.getColumns();
}
}
if (list.size() > 0) {
if (!list.isEmpty()) {
for (Expression[] expr : list) {
if (expr.length != columns.length) {
throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
......
......@@ -1212,7 +1212,7 @@ public class Database implements DataHandler {
trace.info("disconnecting session #{0}", session.getId());
}
}
if (userSessions.size() == 0 &&
if (userSessions.isEmpty() &&
session != systemSession && session != lobSession) {
if (closeDelay == 0) {
close(false);
......@@ -1275,7 +1275,7 @@ public class Database implements DataHandler {
}
closing = true;
stopServer();
if (userSessions.size() > 0) {
if (!userSessions.isEmpty()) {
if (!fromShutdownHook) {
return;
}
......@@ -1290,7 +1290,7 @@ public class Database implements DataHandler {
// set it to null, to make sure it's called only once
eventListener = null;
e.closingDatabase();
if (userSessions.size() > 0) {
if (!userSessions.isEmpty()) {
// if a connection was opened, we can't close the database
return;
}
......
......@@ -63,7 +63,7 @@ public class Engine implements SessionFactory {
}
database = new Database(ci, cipher);
opened = true;
if (database.getAllUsers().size() == 0) {
if (database.getAllUsers().isEmpty()) {
// users is the last thing we add, so if no user is around,
// the database is new (or not initialized correctly)
user = new User(database, database.allocateObjectId(),
......
......@@ -163,7 +163,7 @@ public class FunctionAlias extends SchemaObjectBase {
list.add(javaMethod);
}
}
if (list.size() == 0) {
if (list.isEmpty()) {
throw DbException.get(
ErrorCode.PUBLIC_STATIC_JAVA_METHOD_NOT_FOUND_1,
methodName + " (" + className + ")");
......
......@@ -251,7 +251,7 @@ public class Session extends SessionWithState {
}
}
public String getParsingCreateViewName() {
if (viewNameStack.size() == 0) {
if (viewNameStack.isEmpty()) {
return null;
}
return viewNameStack.peek();
......@@ -652,7 +652,7 @@ public class Session extends SessionWithState {
// increment the data mod count, so that other sessions
// see the changes
// TODO should not rely on locking
if (locks.size() > 0) {
if (!locks.isEmpty()) {
for (int i = 0, size = locks.size(); i < size; i++) {
Table t = locks.get(i);
if (t instanceof MVTable) {
......@@ -726,10 +726,10 @@ public class Session extends SessionWithState {
}
temporaryLobs.clear();
}
if (temporaryResultLobs != null && temporaryResultLobs.size() > 0) {
if (temporaryResultLobs != null && !temporaryResultLobs.isEmpty()) {
long keepYoungerThan = System.nanoTime() -
TimeUnit.MILLISECONDS.toNanos(database.getSettings().lobTimeout);
while (temporaryResultLobs.size() > 0) {
while (!temporaryResultLobs.isEmpty()) {
TimeoutValue tv = temporaryResultLobs.getFirst();
if (onTimeout && tv.created >= keepYoungerThan) {
break;
......@@ -743,7 +743,7 @@ public class Session extends SessionWithState {
}
private void checkCommitRollback() {
if (commitOrRollbackDisabled && locks.size() > 0) {
if (commitOrRollbackDisabled && !locks.isEmpty()) {
throw DbException.get(ErrorCode.COMMIT_ROLLBACK_NOT_ALLOWED);
}
}
......@@ -783,7 +783,7 @@ public class Session extends SessionWithState {
transaction.commit();
transaction = null;
}
if (locks.size() > 0 || needCommit) {
if (!locks.isEmpty() || needCommit) {
database.commit(this);
}
cleanTempTables(false);
......@@ -990,7 +990,7 @@ public class Session extends SessionWithState {
DbException.throwInternalError();
}
}
if (locks.size() > 0) {
if (!locks.isEmpty()) {
// don't use the enhanced for loop to save memory
for (int i = 0, size = locks.size(); i < size; i++) {
Table t = locks.get(i);
......
......@@ -482,7 +482,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
public void removeServer(IOException e, int i, int count) {
trace.debug(e, "removing server because of exception");
transferList.remove(i);
if (transferList.size() == 0 && autoReconnect(count)) {
if (transferList.isEmpty() && autoReconnect(count)) {
return;
}
checkClosed();
......@@ -653,7 +653,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
@Override
public boolean isClosed() {
return transferList == null || transferList.size() == 0;
return transferList == null || transferList.isEmpty();
}
/**
......
......@@ -24,7 +24,7 @@ abstract class SessionWithState implements SessionInterface {
* Re-create the session state using the stored sessionState list.
*/
protected void recreateSessionState() {
if (sessionState != null && sessionState.size() > 0) {
if (sessionState != null && !sessionState.isEmpty()) {
sessionStateUpdating = true;
try {
for (String sql : sessionState) {
......
......@@ -328,7 +328,7 @@ public class Aggregate extends Expression {
Value v = data.getValue(session.getDatabase(), dataType, distinct);
if (type == AggregateType.GROUP_CONCAT) {
ArrayList<Value> list = ((AggregateDataGroupConcat) data).getList();
if (list == null || list.size() == 0) {
if (list == null || list.isEmpty()) {
return ValueNull.INSTANCE;
}
if (groupConcatOrderList != null) {
......
......@@ -624,7 +624,7 @@ public class FullText {
}
}
}
if (rIds == null || rIds.size() == 0) {
if (rIds == null || rIds.isEmpty()) {
return result;
}
PreparedStatement prepSelectRowById = setting.prepare(conn, SELECT_ROW_BY_ID);
......@@ -913,7 +913,7 @@ public class FullText {
for (int i = 0; rs.next(); i++) {
columnTypes[i] = rs.getInt("DATA_TYPE");
}
if (keyList.size() == 0) {
if (keyList.isEmpty()) {
rs = meta.getPrimaryKeys(null,
StringUtils.escapeMetaDataPattern(schemaName),
tableName);
......@@ -921,7 +921,7 @@ public class FullText {
keyList.add(rs.getString("COLUMN_NAME"));
}
}
if (keyList.size() == 0) {
if (keyList.isEmpty()) {
throw throwException("No primary key for table " + tableName);
}
ArrayList<String> indexList = New.arrayList();
......@@ -938,7 +938,7 @@ public class FullText {
Collections.addAll(indexList, StringUtils.arraySplit(columns, ',', true));
}
}
if (indexList.size() == 0) {
if (indexList.isEmpty()) {
indexList.addAll(columnList);
}
index.keys = new int[keyList.size()];
......
......@@ -505,7 +505,7 @@ public class FullTextLucene extends FullText {
for (int i = 0; rs.next(); i++) {
columnTypes[i] = rs.getInt("DATA_TYPE");
}
if (keyList.size() == 0) {
if (keyList.isEmpty()) {
rs = meta.getPrimaryKeys(null,
StringUtils.escapeMetaDataPattern(schemaName),
tableName);
......@@ -513,7 +513,7 @@ public class FullTextLucene extends FullText {
keyList.add(rs.getString("COLUMN_NAME"));
}
}
if (keyList.size() == 0) {
if (keyList.isEmpty()) {
throw throwException("No primary key for table " + tableName);
}
ArrayList<String> indexList = New.arrayList();
......@@ -530,7 +530,7 @@ public class FullTextLucene extends FullText {
StringUtils.arraySplit(cols, ',', true));
}
}
if (indexList.size() == 0) {
if (indexList.isEmpty()) {
indexList.addAll(columnList);
}
keys = new int[keyList.size()];
......
......@@ -202,7 +202,7 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
}
rs.close();
Xid[] result = list.toArray(new Xid[0]);
if (list.size() > 0) {
if (!list.isEmpty()) {
prepared = true;
}
return result;
......
......@@ -241,7 +241,7 @@ public class Trace {
*/
public static String formatParams(
ArrayList<? extends ParameterInterface> parameters) {
if (parameters.size() == 0) {
if (parameters.isEmpty()) {
return "";
}
StatementBuilder buff = new StatementBuilder();
......
......@@ -1479,7 +1479,7 @@ public final class MVStore {
for (Chunk c : modified) {
meta.put(Chunk.getMetaKey(c.id), c.asString());
}
if (modified.size() == 0) {
if (modified.isEmpty()) {
break;
}
}
......@@ -1782,7 +1782,7 @@ public final class MVStore {
synchronized (this) {
old = compactGetOldChunks(targetFillRate, write);
}
if (old == null || old.size() == 0) {
if (old == null || old.isEmpty()) {
return false;
}
compactRewrite(old);
......@@ -1838,7 +1838,7 @@ public final class MVStore {
c.collectPriority = (int) (c.getFillRate() * 1000 / age);
old.add(c);
}
if (old.size() == 0) {
if (old.isEmpty()) {
return null;
}
......@@ -2287,7 +2287,7 @@ public final class MVStore {
keep = c;
}
}
if (remove.size() > 0) {
if (!remove.isEmpty()) {
// remove the youngest first, so we don't create gaps
// (in case we remove many chunks)
Collections.sort(remove, Collections.reverseOrder());
......
......@@ -610,7 +610,7 @@ public class MVTable extends TableBase {
remaining--;
}
sortRows(buffer, index);
if (bufferNames.size() > 0) {
if (!bufferNames.isEmpty()) {
String mapName = store.nextTemporaryMapName();
index.addRowsToBuffer(buffer, mapName);
bufferNames.add(mapName);
......
......@@ -305,7 +305,7 @@ public class SpatialDataType implements DataType {
*/
public int[] getExtremes(ArrayList<Object> list) {
list = getNotNull(list);
if (list.size() == 0) {
if (list.isEmpty()) {
return null;
}
SpatialKey bounds = (SpatialKey) createBoundingBox(list.get(0));
......
......@@ -118,7 +118,7 @@ public class UpdatableRow {
}
private boolean isIndexUsable(ArrayList<String> indexColumns) {
if (indexColumns.size() == 0) {
if (indexColumns.isEmpty()) {
return false;
}
for (String c : indexColumns) {
......
......@@ -182,7 +182,7 @@ public class CipherFactory {
boolean ecdhAnonRemoved = algorithms.remove("ECDH_anon");
if (dhAnonRemoved || ecdhAnonRemoved) {
String string = Arrays.toString(algorithms.toArray(new String[algorithms.size()]));
return (algorithms.size() > 0) ? string.substring(1, string.length() - 1): "";
return (!algorithms.isEmpty()) ? string.substring(1, string.length() - 1): "";
}
return list;
}
......
......@@ -886,7 +886,7 @@ public class PgServerThread implements Runnable {
}
stat.execute("set search_path = PUBLIC, pg_catalog");
HashSet<Integer> typeSet = server.getTypeSet();
if (typeSet.size() == 0) {
if (typeSet.isEmpty()) {
try (ResultSet rs = stat.executeQuery("select oid from pg_catalog.pg_type")) {
while (rs.next()) {
typeSet.add(rs.getInt(1));
......
......@@ -98,7 +98,7 @@ public class PageParser {
result.append("?items?");
list = New.arrayList();
}
if (list.size() == 0) {
if (list.isEmpty()) {
parseBlockUntil("</c:forEach>");
}
for (Object o : list) {
......
......@@ -1869,7 +1869,7 @@ public class WebApp {
String setting = attributes.getProperty("name", "");
server.removeSetting(setting);
ArrayList<ConnectionInfo> settings = server.getSettings();
if (settings.size() > 0) {
if (!settings.isEmpty()) {
attributes.put("setting", settings.get(0));
}
server.saveProperties(null);
......
......@@ -206,7 +206,7 @@ class WebSession {
"${text.admin.notConnected}" : conn.getMetaData().getURL());
m.put("user", conn == null ?
"-" : conn.getMetaData().getUserName());
m.put("lastQuery", commandHistory.size() == 0 ?
m.put("lastQuery", commandHistory.isEmpty() ?
"" : commandHistory.get(0));
m.put("executing", executingStatement == null ?
"${text.admin.no}" : "${text.admin.yes}");
......
......@@ -1407,7 +1407,7 @@ public class PageStore implements CacheWriter {
isEmpty &= log.recover(PageLog.RECOVERY_STAGE_REDO);
boolean setReadOnly = false;
if (!database.isReadOnly()) {
if (log.getInDoubtTransactions().size() == 0) {
if (log.getInDoubtTransactions().isEmpty()) {
log.recoverEnd();
int firstUncommittedSection = getFirstUncommittedSection();
log.removeUntil(firstUncommittedSection);
......
......@@ -671,7 +671,7 @@ public class RegularTable extends TableBase {
lockExclusiveSession = null;
}
synchronized (database) {
if (lockSharedSessions.size() > 0) {
if (!lockSharedSessions.isEmpty()) {
lockSharedSessions.remove(s);
}
if (!waitingSessions.isEmpty()) {
......
......@@ -529,20 +529,20 @@ public abstract class Table extends SchemaObjectBase {
@Override
public void removeChildrenAndResources(Session session) {
while (dependentViews.size() > 0) {
while (!dependentViews.isEmpty()) {
TableView view = dependentViews.get(0);
dependentViews.remove(0);
database.removeSchemaObject(session, view);
}
while (synonyms != null && synonyms.size() > 0) {
while (synonyms != null && !synonyms.isEmpty()) {
TableSynonym synonym = synonyms.remove(0);
database.removeSchemaObject(session, synonym);
}
while (triggers != null && triggers.size() > 0) {
while (triggers != null && !triggers.isEmpty()) {
TriggerObject trigger = triggers.remove(0);
database.removeSchemaObject(session, trigger);
}
while (constraints != null && constraints.size() > 0) {
while (constraints != null && !constraints.isEmpty()) {
Constraint constraint = constraints.remove(0);
database.removeSchemaObject(session, constraint);
}
......@@ -554,7 +554,7 @@ public abstract class Table extends SchemaObjectBase {
database.removeMeta(session, getId());
// must delete sequences later (in case there is a power failure
// before removing the table object)
while (sequences != null && sequences.size() > 0) {
while (sequences != null && !sequences.isEmpty()) {
Sequence sequence = sequences.remove(0);
// only remove if no other table depends on this sequence
// this is possible when calling ALTER TABLE ALTER COLUMN
......@@ -975,8 +975,8 @@ public abstract class Table extends SchemaObjectBase {
* @return if there are any triggers or rows defined
*/
public boolean fireRow() {
return (constraints != null && constraints.size() > 0) ||
(triggers != null && triggers.size() > 0);
return (constraints != null && !constraints.isEmpty()) ||
(triggers != null && !triggers.isEmpty());
}
/**
......
......@@ -197,7 +197,7 @@ public class TableFilter implements ColumnResolver {
if (select != null) {
sortOrder = select.getSortOrder();
}
if (indexConditions.size() == 0) {
if (indexConditions.isEmpty()) {
item1 = new PlanItem();
item1.setIndex(table.getScanIndex(s, null, filters, filter,
sortOrder, allColumnsSet));
......@@ -854,7 +854,7 @@ public class TableFilter implements ColumnResolver {
}
}
planBuff.append(index.getPlanSQL());
if (indexConditions.size() > 0) {
if (!indexConditions.isEmpty()) {
planBuff.append(": ");
for (IndexCondition condition : indexConditions) {
planBuff.appendExceptFirst("\n AND ");
......
......@@ -173,7 +173,7 @@ public class TableLink extends Table {
try (Statement stat = conn.getConnection().createStatement()) {
rs = stat.executeQuery("SELECT * FROM " +
qualifiedTableName + " T WHERE 1=0");
if (columnList.size() == 0) {
if (columnList.isEmpty()) {
// alternative solution
ResultSetMetaData rsMeta = rs.getMetaData();
for (i = 0; i < rsMeta.getColumnCount();) {
......@@ -501,7 +501,7 @@ public class TableLink extends Table {
if (trace.isDebugEnabled()) {
StatementBuilder buff = new StatementBuilder();
buff.append(getName()).append(":\n").append(sql);
if (params != null && params.size() > 0) {
if (params != null && !params.isEmpty()) {
buff.append(" {");
int i = 1;
for (Value v : params) {
......
......@@ -114,7 +114,7 @@ public class Backup extends Tool {
} else {
list = FileLister.getDatabaseFiles(directory, db, true);
}
if (list.size() == 0) {
if (list.isEmpty()) {
if (!quiet) {
printNoDatabaseFilesFound(directory, db);
}
......
......@@ -170,7 +170,7 @@ public class ChangeFileEncryption extends Tool {
ArrayList<String> files = FileLister.getDatabaseFiles(dir, db, true);
FileLister.tryUnlockDatabase(files, "encryption");
files = FileLister.getDatabaseFiles(dir, db, false);
if (files.size() == 0 && !quiet) {
if (files.isEmpty() && !quiet) {
printNoDatabaseFilesFound(dir, db);
}
// first, test only if the file can be renamed
......
......@@ -343,7 +343,7 @@ public class Csv implements SimpleRowSource {
String v = readValue();
if (v == null) {
if (endOfLine) {
if (endOfFile || list.size() > 0) {
if (endOfFile || !list.isEmpty()) {
break;
}
} else {
......
......@@ -84,7 +84,7 @@ public class DeleteDbFiles extends Tool {
*/
private void process(String dir, String db, boolean quiet) {
ArrayList<String> files = FileLister.getDatabaseFiles(dir, db, true);
if (files.size() == 0 && !quiet) {
if (files.isEmpty() && !quiet) {
printNoDatabaseFilesFound(dir, db);
}
for (String fileName : files) {
......
......@@ -330,7 +330,7 @@ public class Recover extends Tool implements DataHandler {
private void process(String dir, String db) {
ArrayList<String> list = FileLister.getDatabaseFiles(dir, db, true);
if (list.size() == 0) {
if (list.isEmpty()) {
printNoDatabaseFilesFound(dir, db);
}
for (String fileName : list) {
......
......@@ -243,7 +243,7 @@ public class Shell extends Tool implements Runnable {
s = s.replace('\n', ' ').replace('\r', ' ');
println("#" + (1 + i) + ": " + s);
}
if (history.size() > 0) {
if (!history.isEmpty()) {
println("To re-run a statement, type the number and press and enter");
} else {
println("No history");
......
......@@ -116,7 +116,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
*/
public void addColumn(String name, int sqlType, String sqlTypeName,
int precision, int scale) {
if (rows != null && rows.size() > 0) {
if (rows != null && !rows.isEmpty()) {
throw new IllegalStateException(
"Cannot add a column after adding rows");
}
......
......@@ -71,7 +71,7 @@ public class AbbaDetector {
System.out.println(thread + " " + indent +
"sync " + getObjectName(o));
}
if (stack.size() > 0) {
if (!stack.isEmpty()) {
markHigher(o, stack);
}
stack.push(o);
......
......@@ -163,7 +163,7 @@ public class CacheLRU implements Cache {
if (rc <= Constants.CACHE_MIN_RECORDS) {
break;
}
if (changed.size() == 0) {
if (changed.isEmpty()) {
if (mem <= maxMemory) {
break;
}
......@@ -209,7 +209,7 @@ public class CacheLRU implements Cache {
remove(check.getPos());
}
}
if (changed.size() > 0) {
if (!changed.isEmpty()) {
if (!flushed) {
writer.flushLog();
}
......
......@@ -253,7 +253,7 @@ public class Profiler implements Runnable {
line = line.substring(3).trim();
stack.add(line);
}
if (stack.size() > 0) {
if (!stack.isEmpty()) {
String[] s = stack.toArray(new String[0]);
list.add(s);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论